|
15 | 15 |
|
16 | 16 | import static com.google.common.base.Preconditions.checkNotNull;
|
17 | 17 |
|
| 18 | +import java.time.Duration; |
18 | 19 | import java.util.OptionalInt;
|
19 | 20 | import java.util.function.Consumer;
|
20 | 21 | import tech.pegasys.teku.infrastructure.exceptions.InvalidConfigurationException;
|
|
25 | 26 | import tech.pegasys.teku.networking.p2p.network.config.NetworkConfig;
|
26 | 27 | import tech.pegasys.teku.spec.Spec;
|
27 | 28 | import tech.pegasys.teku.spec.config.NetworkingSpecConfig;
|
| 29 | +import tech.pegasys.teku.spec.config.SpecConfig; |
28 | 30 |
|
29 | 31 | public class P2PConfig {
|
30 | 32 |
|
@@ -182,14 +184,21 @@ public P2PConfig build() {
|
182 | 184 | isGossipScoringEnabled
|
183 | 185 | ? GossipConfigurator.scoringEnabled(spec)
|
184 | 186 | : GossipConfigurator.NOOP;
|
| 187 | + final SpecConfig specConfig = spec.getGenesisSpecConfig(); |
185 | 188 | final Eth2Context eth2Context =
|
186 | 189 | Eth2Context.builder()
|
187 |
| - .activeValidatorCount(spec.getGenesisSpecConfig().getMinGenesisActiveValidatorCount()) |
| 190 | + .activeValidatorCount(specConfig.getMinGenesisActiveValidatorCount()) |
188 | 191 | .gossipEncoding(gossipEncoding)
|
189 | 192 | .build();
|
190 |
| - networkConfig.gossipConfig(c -> gossipConfigurator.configure(c, eth2Context)); |
191 |
| - |
192 |
| - NetworkConfig networkConfig = this.networkConfig.build(); |
| 193 | + networkConfig.gossipConfig( |
| 194 | + builder -> { |
| 195 | + gossipConfigurator.configure(builder, eth2Context); |
| 196 | + builder.seenTTL( |
| 197 | + Duration.ofSeconds( |
| 198 | + (long) specConfig.getSecondsPerSlot() * specConfig.getSlotsPerEpoch() * 2)); |
| 199 | + }); |
| 200 | + |
| 201 | + final NetworkConfig networkConfig = this.networkConfig.build(); |
193 | 202 | discoveryConfig.listenUdpPortDefault(networkConfig.getListenPort());
|
194 | 203 | discoveryConfig.advertisedUdpPortDefault(OptionalInt.of(networkConfig.getAdvertisedPort()));
|
195 | 204 |
|
|
0 commit comments