Skip to content

Commit 2e9c8fd

Browse files
shazowkaralabe
authored andcommitted
eth, les: allow exceeding maxPeers for trusted peers (#16189)
Fixes bnb-chain#3326, #14472
1 parent 4c845bd commit 2e9c8fd

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

‎eth/handler.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,8 @@ func (pm *ProtocolManager) newPeer(pv int, p *p2p.Peer, rw p2p.MsgReadWriter) *p
249249
// handle is the callback invoked to manage the life cycle of an eth peer. When
250250
// this function terminates, the peer is disconnected.
251251
func (pm *ProtocolManager) handle(p *peer) error {
252-
if pm.peers.Len() >= pm.maxPeers {
252+
// Ignore maxPeers if this is a trusted peer
253+
if pm.peers.Len() >= pm.maxPeers && !p.Peer.Info().Network.Trusted {
253254
return p2p.DiscTooManyPeers
254255
}
255256
p.Log().Debug("Ethereum peer connected", "name", p.Name())

‎les/handler.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,8 @@ func (pm *ProtocolManager) newPeer(pv int, nv uint64, p *p2p.Peer, rw p2p.MsgRea
260260
// handle is the callback invoked to manage the life cycle of a les peer. When
261261
// this function terminates, the peer is disconnected.
262262
func (pm *ProtocolManager) handle(p *peer) error {
263-
if pm.peers.Len() >= pm.maxPeers {
263+
// Ignore maxPeers if this is a trusted peer
264+
if pm.peers.Len() >= pm.maxPeers && !p.Peer.Info().Network.Trusted {
264265
return p2p.DiscTooManyPeers
265266
}
266267

0 commit comments

Comments
 (0)