use of tech.pegasys.teku.storage.store.FileKeyValueStore in project teku by ConsenSys.
the class BeaconChainController method initP2PNetwork.
protected void initP2PNetwork() {
LOG.debug("BeaconChainController.initP2PNetwork()");
if (!beaconConfig.p2pConfig().getNetworkConfig().isEnabled()) {
this.p2pNetwork = new NoOpEth2P2PNetwork(spec);
return;
}
DiscoveryConfig discoveryConfig = beaconConfig.p2pConfig().getDiscoveryConfig();
final Optional<Integer> maybeUdpPort = discoveryConfig.isDiscoveryEnabled() ? Optional.of(discoveryConfig.getListenUdpPort()) : Optional.empty();
PortAvailability.checkPortsAvailable(beaconConfig.p2pConfig().getNetworkConfig().getListenPort(), maybeUdpPort);
final KeyValueStore<String, Bytes> keyValueStore = new FileKeyValueStore(beaconDataDirectory.resolve(KEY_VALUE_STORE_SUBDIRECTORY));
this.p2pNetwork = createEth2P2PNetworkBuilder().config(beaconConfig.p2pConfig()).eventChannels(eventChannels).recentChainData(recentChainData).gossipedBlockProcessor(blockManager::validateAndImportBlock).gossipedAttestationProcessor(attestationManager::addAttestation).gossipedAggregateProcessor(attestationManager::addAggregate).gossipedAttesterSlashingProcessor(attesterSlashingPool::add).gossipedProposerSlashingProcessor(proposerSlashingPool::add).gossipedVoluntaryExitProcessor(voluntaryExitPool::add).gossipedSignedContributionAndProofProcessor(syncCommitteeContributionPool::add).gossipedSyncCommitteeMessageProcessor(syncCommitteeMessagePool::add).processedAttestationSubscriptionProvider(attestationManager::subscribeToAttestationsToSend).historicalChainData(eventChannels.getPublisher(StorageQueryChannel.class, beaconAsyncRunner)).metricsSystem(metricsSystem).timeProvider(timeProvider).asyncRunner(networkAsyncRunner).keyValueStore(keyValueStore).requiredCheckpoint(weakSubjectivityValidator.getWSCheckpoint()).specProvider(spec).build();
syncCommitteeMessagePool.subscribeOperationAdded(new OperationAcceptedFilter<>(p2pNetwork::publishSyncCommitteeMessage));
syncCommitteeContributionPool.subscribeOperationAdded(new OperationAcceptedFilter<>(p2pNetwork::publishSyncCommitteeContribution));
proposerSlashingPool.subscribeOperationAdded(new OperationAcceptedFilter<>(p2pNetwork::publishProposerSlashing));
attesterSlashingPool.subscribeOperationAdded(new OperationAcceptedFilter<>(p2pNetwork::publishAttesterSlashing));
voluntaryExitPool.subscribeOperationAdded(new OperationAcceptedFilter<>(p2pNetwork::publishVoluntaryExit));
}
Aggregations