use of org.hyperledger.besu.ethereum.eth.sync.fastsync.TransitionPivotSelector in project besu by hyperledger.
the class BesuControllerBuilder method createPivotSelector.
private PivotBlockSelector createPivotSelector(final ProtocolContext protocolContext) {
final PivotSelectorFromPeers pivotSelectorFromPeers = new PivotSelectorFromPeers(syncConfig);
final GenesisConfigOptions genesisConfigOptions = configOptionsSupplier.get();
if (genesisConfigOptions.getTerminalTotalDifficulty().isPresent()) {
LOG.info("TTD difficulty is present, creating initial sync phase with transition to PoS support");
final MergeContext mergeContext = protocolContext.getConsensusContext(MergeContext.class);
final FinalizedBlockHashSupplier finalizedBlockHashSupplier = new FinalizedBlockHashSupplier();
final long subscriptionId = mergeContext.addNewForkchoiceMessageListener(finalizedBlockHashSupplier);
final Runnable unsubscribeFinalizedBlockHashListener = () -> {
mergeContext.removeNewForkchoiceMessageListener(subscriptionId);
LOG.info("Initial sync done, unsubscribe finalized block hash supplier");
};
return new TransitionPivotSelector(genesisConfigOptions, finalizedBlockHashSupplier, pivotSelectorFromPeers, new PivotSelectorFromFinalizedBlock(genesisConfigOptions, finalizedBlockHashSupplier, unsubscribeFinalizedBlockHashListener));
} else {
LOG.info("TTD difficulty is not present, creating initial sync phase for PoW");
return pivotSelectorFromPeers;
}
}
Aggregations