mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-16 04:56:36 +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.
|
// dropRandomPeer selects one of the peers randomly and drops it from the peer pool.
|
||||||
func (cm *connManager) dropRandomPeer() bool {
|
func (cm *connManager) dropRandomPeer() bool {
|
||||||
peers := cm.peersFunc()
|
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 {
|
if len(droppable) > 0 {
|
||||||
p := droppable[cm.rand.Intn(len(droppable))]
|
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))
|
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