mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-24 08:49:29 +00:00
eth: skip protection work in dropper when pools have headroom
When neither the dialed nor inbound peer pool is close to capacity, every non-trusted/non-static peer is already marked do-not-drop by the pool-threshold rules in selectDoNotDrop, so the droppable set is guaranteed empty regardless of inclusion protection. Return early in that case to avoid the wasted peerStatsFunc call, per-direction split, and per-category sort in protectedPeers.
This commit is contained in:
parent
d7fddf418e
commit
ed3d5ab3da
1 changed files with 8 additions and 0 deletions
|
|
@ -164,6 +164,14 @@ func (cm *dropper) dropRandomPeer() bool {
|
|||
}
|
||||
numDialed := len(peers) - numInbound
|
||||
|
||||
// Fast path: if neither pool is near capacity, every non-trusted/non-static
|
||||
// peer is already do-not-drop by pool-threshold rules. No point computing
|
||||
// inclusion protection.
|
||||
if cm.maxDialPeers-numDialed > peerDropThreshold &&
|
||||
cm.maxInboundPeers-numInbound > peerDropThreshold {
|
||||
return false
|
||||
}
|
||||
|
||||
// Compute the set of inclusion-protected peers before filtering.
|
||||
protected := cm.protectedPeers(peers)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue