From d6f439157d27e1d1eb821802a91be909df85a3d3 Mon Sep 17 00:00:00 2001 From: Sean Zellmer Date: Tue, 19 May 2026 14:11:14 -0500 Subject: [PATCH] Limit # of peers used in non-primary update Reduces messages while still allowing ranges etc to be bumped with random peers. --- lib/replicator.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/replicator.js b/lib/replicator.js index 369a6f08..a6e17ec7 100644 --- a/lib/replicator.js +++ b/lib/replicator.js @@ -47,6 +47,7 @@ const DEFAULT_MAX_INFLIGHT = [16, 512] const SCALE_LATENCY = 50 const NOT_DOWNLOADING_SLACK = (20000 + Math.random() * 20000) | 0 const MAX_PEERS_UPGRADE = 3 +const MAX_PEERS_NON_PRIMARY = 50 const LAST_BLOCKS = 256 const MAX_RANGES = 64 @@ -3039,10 +3040,13 @@ module.exports = class Replicator { return } + let tries = 0 for (const peer of peers.restart()) { + if (tries >= MAX_PEERS_NON_PRIMARY) break if (this._updatePeerNonPrimary(peer) === true) { peers.requeue() } + tries++ } this._checkUpgradeIfAvailable()