Browse Source

pex: dial seeds when address book needs more addresses (#3603)

If we are low on addresses for peering, we need to discover more peers. The
previous behavior would query existing peers; however, if an existing peer
does not participate in peer exchange, then our node will not discover more peers.

This change consults both existing peers as well as seeds when there is a deficit
in address book addresses. This allows for discovering peers though existing channels
as well as via seeds if existing peers do not share addresses.
pull/3606/head
Roman Shtylman 5 years ago
committed by Anton Kaliaev
parent
commit
40dbad9915
2 changed files with 5 additions and 3 deletions
  1. +1
    -0
      CHANGELOG_PENDING.md
  2. +4
    -3
      p2p/pex/pex_reactor.go

+ 1
- 0
CHANGELOG_PENDING.md View File

@ -27,3 +27,4 @@
- [p2p] \#3532 limit the number of attempts to connect to a peer in seed mode
to 16 (as a result, the node will stop retrying after a 35 hours time window)
- [consensus] \#2723, \#3451 and \#3317 Fix non-deterministic tests
- [pex] \#3603 Dial seeds when addrbook needs more addresses (@defunctzombie)

+ 4
- 3
p2p/pex/pex_reactor.go View File

@ -493,9 +493,10 @@ func (r *PEXReactor) ensurePeers() {
}
}
// If we are not connected to nor dialing anybody, fallback to dialing a seed.
if out+in+dial+len(toDial) == 0 {
r.Logger.Info("No addresses to dial nor connected peers. Falling back to seeds")
// If we are not dialing anyone and need more addresses - dial a seed
// This is done in addition to asking a peer for addresses to work-around peers not participating in PEX
if r.book.NeedMoreAddrs() && len(toDial) == 0 {
r.Logger.Info("No addresses to dial. Falling back to seeds")
r.dialSeeds()
}
}


Loading…
Cancel
Save