Search in sources :

Example 1 with FileKeyValueStore

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));
}
Also used : FileKeyValueStore(tech.pegasys.teku.storage.store.FileKeyValueStore) Bytes(org.apache.tuweni.bytes.Bytes) StorageQueryChannel(tech.pegasys.teku.storage.api.StorageQueryChannel) NoOpEth2P2PNetwork(tech.pegasys.teku.networking.eth2.mock.NoOpEth2P2PNetwork) DiscoveryConfig(tech.pegasys.teku.networking.p2p.discovery.DiscoveryConfig)

Aggregations

Bytes (org.apache.tuweni.bytes.Bytes)1 NoOpEth2P2PNetwork (tech.pegasys.teku.networking.eth2.mock.NoOpEth2P2PNetwork)1 DiscoveryConfig (tech.pegasys.teku.networking.p2p.discovery.DiscoveryConfig)1 StorageQueryChannel (tech.pegasys.teku.storage.api.StorageQueryChannel)1 FileKeyValueStore (tech.pegasys.teku.storage.store.FileKeyValueStore)1