use of org.hyperledger.besu.ethereum.eth.peervalidation.CheckpointBlocksPeerValidator 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