Search in sources :

Example 1 with ClassicForkPeerValidator

use of org.hyperledger.besu.ethereum.eth.peervalidation.ClassicForkPeerValidator in project besu by hyperledger.

the class BesuControllerBuilder method createPeerValidators.

protected List<PeerValidator> createPeerValidators(final ProtocolSchedule protocolSchedule) {
    final List<PeerValidator> validators = new ArrayList<>();
    final OptionalLong daoBlock = configOptionsSupplier.get().getDaoForkBlock();
    if (daoBlock.isPresent()) {
        // Setup dao validator
        validators.add(new DaoForkPeerValidator(protocolSchedule, metricsSystem, daoBlock.getAsLong()));
    }
    final OptionalLong classicBlock = configOptionsSupplier.get().getClassicForkBlock();
    // setup classic validator
    if (classicBlock.isPresent()) {
        validators.add(new ClassicForkPeerValidator(protocolSchedule, metricsSystem, classicBlock.getAsLong()));
    }
    for (final Map.Entry<Long, Hash> requiredBlock : requiredBlocks.entrySet()) {
        validators.add(new RequiredBlocksPeerValidator(protocolSchedule, metricsSystem, requiredBlock.getKey(), requiredBlock.getValue()));
    }
    final CheckpointConfigOptions checkpointConfigOptions = genesisConfig.getConfigOptions(genesisConfigOverrides).getCheckpointOptions();
    if (SyncMode.X_CHECKPOINT.equals(syncConfig.getSyncMode()) && checkpointConfigOptions.isValid()) {
        validators.add(new CheckpointBlocksPeerValidator(protocolSchedule, metricsSystem, checkpointConfigOptions.getNumber().orElseThrow(), checkpointConfigOptions.getHash().map(Hash::fromHexString).orElseThrow()));
    }
    return validators;
}
Also used : CheckpointBlocksPeerValidator(org.hyperledger.besu.ethereum.eth.peervalidation.CheckpointBlocksPeerValidator) ArrayList(java.util.ArrayList) ClassicForkPeerValidator(org.hyperledger.besu.ethereum.eth.peervalidation.ClassicForkPeerValidator) Hash(org.hyperledger.besu.datatypes.Hash) DaoForkPeerValidator(org.hyperledger.besu.ethereum.eth.peervalidation.DaoForkPeerValidator) ClassicForkPeerValidator(org.hyperledger.besu.ethereum.eth.peervalidation.ClassicForkPeerValidator) CheckpointBlocksPeerValidator(org.hyperledger.besu.ethereum.eth.peervalidation.CheckpointBlocksPeerValidator) RequiredBlocksPeerValidator(org.hyperledger.besu.ethereum.eth.peervalidation.RequiredBlocksPeerValidator) PeerValidator(org.hyperledger.besu.ethereum.eth.peervalidation.PeerValidator) DaoForkPeerValidator(org.hyperledger.besu.ethereum.eth.peervalidation.DaoForkPeerValidator) OptionalLong(java.util.OptionalLong) CheckpointConfigOptions(org.hyperledger.besu.config.CheckpointConfigOptions) OptionalLong(java.util.OptionalLong) Map(java.util.Map) RequiredBlocksPeerValidator(org.hyperledger.besu.ethereum.eth.peervalidation.RequiredBlocksPeerValidator)

Aggregations

ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 OptionalLong (java.util.OptionalLong)1 CheckpointConfigOptions (org.hyperledger.besu.config.CheckpointConfigOptions)1 Hash (org.hyperledger.besu.datatypes.Hash)1 CheckpointBlocksPeerValidator (org.hyperledger.besu.ethereum.eth.peervalidation.CheckpointBlocksPeerValidator)1 ClassicForkPeerValidator (org.hyperledger.besu.ethereum.eth.peervalidation.ClassicForkPeerValidator)1 DaoForkPeerValidator (org.hyperledger.besu.ethereum.eth.peervalidation.DaoForkPeerValidator)1 PeerValidator (org.hyperledger.besu.ethereum.eth.peervalidation.PeerValidator)1 RequiredBlocksPeerValidator (org.hyperledger.besu.ethereum.eth.peervalidation.RequiredBlocksPeerValidator)1