Skip to content

Commit

Permalink
correct logic
Browse files Browse the repository at this point in the history
  • Loading branch information
czarcas7ic committed Jun 25, 2024
1 parent 33eecc7 commit 372f252
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions p2p/pex/pex_reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ func (r *Reactor) ensurePeers() {

if r.book.NeedMoreAddrs() {
// If we still need more addresses, request more from peers or dial seeds.
r.requestMoreAddresses()
r.requestMoreAddresses(len(toDial))
}
}

Expand Down Expand Up @@ -576,7 +576,7 @@ func (r *Reactor) dialAddresses(toDial map[p2p.ID]*p2p.NetAddress, numToDial int
}
}

func (r *Reactor) requestMoreAddresses() {
func (r *Reactor) requestMoreAddresses(numDialed int) {
peers := r.Switch.Peers().List()
if len(peers) > 0 {
// 1) Pick a random peer and ask for more.
Expand All @@ -585,7 +585,7 @@ func (r *Reactor) requestMoreAddresses() {
r.RequestAddrs(peer)
}

if len(peers) == 0 {
if numDialed == 0 {
// 2) Dial seeds if we are not dialing anyone.
// This is done in addition to asking a peer for addresses to work-around
// peers not participating in PEX.
Expand Down

0 comments on commit 372f252

Please sign in to comment.