Skip to content

Commit

Permalink
remove limiting in peer tracker
Browse files Browse the repository at this point in the history
  • Loading branch information
vgonkivs committed Apr 1, 2024
1 parent 3b63466 commit 61513d0
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions p2p/peer_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@ import (
"github.com/libp2p/go-libp2p/p2p/net/conngater"
)

const (
// defaultScore specifies the score for newly connected peers.
defaultScore float32 = 1
// maxPeerTrackerSize specifies the max amount of peers that can be added to the peerTracker.
maxPeerTrackerSize = 100
)
// defaultScore specifies the score for newly connected peers.
const defaultScore float32 = 1

var (
// maxAwaitingTime specifies the duration that gives to the disconnected peer to be back online,
Expand Down Expand Up @@ -177,13 +173,6 @@ func (p *peerTracker) connected(pID libpeer.ID) {

p.peerLk.Lock()
defer p.peerLk.Unlock()
// skip adding the peer to avoid overfilling of the peerTracker with unused peers if:
// peerTracker reaches the maxTrackerSize and there are more connected peers
// than disconnected peers.
if len(p.trackedPeers)+len(p.disconnectedPeers) > maxPeerTrackerSize &&
len(p.trackedPeers) > len(p.disconnectedPeers) {
return
}

// additional check in p.trackedPeers should be done,
// because libp2p does not emit multiple Connected events per 1 peer
Expand Down

0 comments on commit 61513d0

Please sign in to comment.