diff --git a/beacon_chain/sync/branch_discovery.nim b/beacon_chain/sync/branch_discovery.nim index 8e3d1ca3e..ba3d02292 100644 --- a/beacon_chain/sync/branch_discovery.nim +++ b/beacon_chain/sync/branch_discovery.nim @@ -299,9 +299,12 @@ proc resume*(self: ref BranchDiscovery) = proc transferOwnership*(self: ref BranchDiscovery, peer: Peer) = const maxPeersInQueue = 10 if self.state != BranchDiscoveryState.Active or - self[].peerQueue.len >= maxPeersInQueue: + self[].peerQueue.len >= maxPeersInQueue or + peer.getHeadSlot() <= self[].getFinalizedSlot() or + self[].isBlockKnown(peer.getHeadRoot()): self[].network.peerPool.release(peer) return + debug "Peer transferred to branch discovery", peer, peer_score = peer.getScore() self[].peerQueue.addLast(peer) diff --git a/beacon_chain/sync/sync_manager.nim b/beacon_chain/sync/sync_manager.nim index 745d4af3e..3640980e8 100644 --- a/beacon_chain/sync/sync_manager.nim +++ b/beacon_chain/sync/sync_manager.nim @@ -526,7 +526,7 @@ proc syncWorker[A, B](man: SyncManager[A, B], index: int) {.async: (raises: [Can peer = await man.pool.acquire() await man.syncStep(index, peer) if man.workers[index].status < SyncWorkerStatus.Downloading and - man.fallbackSyncer != nil: + peer.getScore() >= PeerScoreLowLimit and man.fallbackSyncer != nil: # The peer was not useful for us, hand it over to the fallback syncer. # It is the responsibility of the fallback syncer to release the peer man.fallbackSyncer(peer)