mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-03-01 17:13:45 +00:00
p2p/connmanager: only drop from dialed peers
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
parent
136d32d2c0
commit
7a49bf09c1
1 changed files with 4 additions and 1 deletions
|
|
@ -131,7 +131,10 @@ func (cm *connManager) numPeers() (int, int, int) {
|
|||
// dropRandomPeer selects one of the peers randomly and drops it from the peer pool.
|
||||
func (cm *connManager) dropRandomPeer() bool {
|
||||
peers := cm.peersFunc()
|
||||
droppable := peers
|
||||
|
||||
// only drop from dialed peers
|
||||
selectDroppable := func(p *Peer) bool { return !p.rw.is(inboundConn) }
|
||||
droppable := filter(peers, selectDroppable)
|
||||
if len(droppable) > 0 {
|
||||
p := droppable[cm.rand.Intn(len(droppable))]
|
||||
cm.log.Trace("dropping random peer", "id", p.ID(), "duration", common.PrettyDuration(mclock.Now()-p.created), "peercountbefore", len(peers))
|
||||
|
|
|
|||
Loading…
Reference in a new issue