use of org.hyperledger.besu.ethereum.eth.peervalidation.RequiredBlocksPeerValidator in project besu by hyperledger.
the class MergeBesuControllerBuilder method createPeerValidators.
@Override
protected List<PeerValidator> createPeerValidators(final ProtocolSchedule protocolSchedule) {
List<PeerValidator> retval = super.createPeerValidators(protocolSchedule);
final OptionalLong powTerminalBlockNumber = configOptionsSupplier.get().getTerminalBlockNumber();
final Optional<Hash> powTerminalBlockHash = configOptionsSupplier.get().getTerminalBlockHash();
if (powTerminalBlockHash.isPresent() && powTerminalBlockNumber.isPresent()) {
retval.add(new RequiredBlocksPeerValidator(protocolSchedule, metricsSystem, powTerminalBlockNumber.getAsLong(), powTerminalBlockHash.get(), 0));
} else {
LOG.debug("unable to validate peers with terminal difficulty blocks");
}
return retval;
}
use of org.hyperledger.besu.ethereum.eth.peervalidation.RequiredBlocksPeerValidator 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;
}
Aggregations