use of tech.pegasys.teku.networking.eth2.peers.Eth2PeerManager in project teku by ConsenSys.
the class Eth2P2PNetworkBuilder method build.
public Eth2P2PNetwork build() {
validate();
// Setup eth2 handlers
final SubnetSubscriptionService attestationSubnetService = new SubnetSubscriptionService();
final SubnetSubscriptionService syncCommitteeSubnetService = new SubnetSubscriptionService();
final RpcEncoding rpcEncoding = RpcEncoding.createSszSnappyEncoding(spec.isMilestoneSupported(SpecMilestone.BELLATRIX) ? MAX_CHUNK_SIZE_BELLATRIX : MAX_CHUNK_SIZE);
final Eth2PeerManager eth2PeerManager = Eth2PeerManager.create(asyncRunner, recentChainData, historicalChainData, metricsSystem, attestationSubnetService, syncCommitteeSubnetService, rpcEncoding, requiredCheckpoint, eth2RpcPingInterval, eth2RpcOutstandingPingThreshold, eth2StatusUpdateInterval, timeProvider, config.getPeerRateLimit(), config.getPeerRequestLimit(), spec);
final Collection<RpcMethod<?, ?, ?>> eth2RpcMethods = eth2PeerManager.getBeaconChainMethods().all();
rpcMethods.addAll(eth2RpcMethods);
peerHandlers.add(eth2PeerManager);
final GossipEncoding gossipEncoding = config.getGossipEncoding();
// Build core network and inject eth2 handlers
final DiscoveryNetwork<?> network = buildNetwork(gossipEncoding, syncCommitteeSubnetService);
final GossipForkManager gossipForkManager = buildGossipForkManager(gossipEncoding, network);
return new ActiveEth2P2PNetwork(config.getSpec(), asyncRunner, network, eth2PeerManager, gossipForkManager, eventChannels, recentChainData, attestationSubnetService, syncCommitteeSubnetService, gossipEncoding, config.getGossipConfigurator(), processedAttestationSubscriptionProvider);
}
use of tech.pegasys.teku.networking.eth2.peers.Eth2PeerManager in project teku by ConsenSys.
the class Eth2PeerManager method create.
public static Eth2PeerManager create(final AsyncRunner asyncRunner, final RecentChainData recentChainData, final StorageQueryChannel historicalChainData, final MetricsSystem metricsSystem, final SubnetSubscriptionService attestationSubnetService, final SubnetSubscriptionService syncCommitteeSubnetService, final RpcEncoding rpcEncoding, final Optional<Checkpoint> requiredCheckpoint, final Duration eth2RpcPingInterval, final int eth2RpcOutstandingPingThreshold, final Duration eth2StatusUpdateInterval, final TimeProvider timeProvider, final int peerRateLimit, final int peerRequestLimit, final Spec spec) {
final StatusMessageFactory statusMessageFactory = new StatusMessageFactory(recentChainData);
final MetadataMessagesFactory metadataMessagesFactory = new MetadataMessagesFactory();
attestationSubnetService.subscribeToUpdates(metadataMessagesFactory::updateAttestationSubnetIds);
syncCommitteeSubnetService.subscribeToUpdates(metadataMessagesFactory::updateSyncCommitteeSubnetIds);
final CombinedChainDataClient combinedChainDataClient = new CombinedChainDataClient(recentChainData, historicalChainData, spec);
return new Eth2PeerManager(spec, asyncRunner, combinedChainDataClient, recentChainData, metricsSystem, new Eth2PeerFactory(spec, metricsSystem, combinedChainDataClient, statusMessageFactory, metadataMessagesFactory, timeProvider, requiredCheckpoint, peerRateLimit, peerRequestLimit), statusMessageFactory, metadataMessagesFactory, rpcEncoding, eth2RpcPingInterval, eth2RpcOutstandingPingThreshold, eth2StatusUpdateInterval);
}
Aggregations