use of tech.pegasys.teku.beacon.sync.forward.multipeer.batches.PeerScoringConflictResolutionStrategy in project teku by ConsenSys.
the class MultipeerSyncService method create.
public static MultipeerSyncService create(final AsyncRunnerFactory asyncRunnerFactory, final AsyncRunner asyncRunner, final TimeProvider timeProvider, final RecentChainData recentChainData, final PendingPool<SignedBeaconBlock> pendingBlocks, final P2PNetwork<Eth2Peer> p2pNetwork, final BlockImporter blockImporter, final Spec spec) {
LOG.info("Using multipeer sync");
final EventThread eventThread = new AsyncRunnerEventThread("sync", asyncRunnerFactory);
final TargetChains finalizedTargetChains = new TargetChains();
final TargetChains nonfinalizedTargetChains = new TargetChains();
final BatchSync batchSync = BatchSync.create(eventThread, asyncRunner, recentChainData, new BatchImporter(blockImporter, asyncRunner), new BatchFactory(eventThread, new PeerScoringConflictResolutionStrategy()), Constants.SYNC_BATCH_SIZE, MultipeerCommonAncestorFinder.create(recentChainData, eventThread, spec), timeProvider);
final SyncController syncController = new SyncController(eventThread, new OrderedAsyncRunner(asyncRunner), recentChainData, new SyncTargetSelector(recentChainData, pendingBlocks, finalizedTargetChains, nonfinalizedTargetChains, spec.getSlotsPerEpoch(recentChainData.getCurrentSlot().orElse(UInt64.ZERO))), batchSync);
final PeerChainTracker peerChainTracker = new PeerChainTracker(recentChainData.getSpec(), eventThread, p2pNetwork, new SyncSourceFactory(asyncRunner, timeProvider), finalizedTargetChains, nonfinalizedTargetChains);
peerChainTracker.subscribeToTargetChainUpdates(syncController::onTargetChainsUpdated);
final SyncStallDetector syncStallDetector = new SyncStallDetector(spec, eventThread, asyncRunner, timeProvider, syncController, batchSync, recentChainData);
return new MultipeerSyncService(eventThread, recentChainData, peerChainTracker, syncController, syncStallDetector);
}
Aggregations