mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-24 22:32:15 +00:00
p2p/pex: consult seeds in crawlPeersRoutine (#3647)
* p2p/pex: consult seeds in crawlPeersRoutine This changeset alters the startup behavior for crawlPeersRoutine. Previously the routine would crawl a random selection of peers on startup. For a new seed node, there are no peers. As a result, new seed nodes are unable to bootstrap themselves with a list of peers until another node with a list of peers connects to the seed. If this node relies on the seed node for peers, then the two will not discover more peers. This changeset makes the startup behavior for crawlPeersRoutine connect to any seed nodes. Upon connecting, a request for peers will be sent to the seed node thus helping bootstrap our seed node. * p2p/pex: Adjust error message for no peers Co-Authored-By: Ethan Buchman <ethan@coinculture.info>
This commit is contained in:
parent
86cf8ee3f9
commit
f1f243d749
@ -145,7 +145,7 @@ func (r *PEXReactor) OnStart() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
} else if numOnline == 0 && r.book.Empty() {
|
} else if numOnline == 0 && r.book.Empty() {
|
||||||
return errors.New("Address book is empty, and could not connect to any seed nodes")
|
return errors.New("Address book is empty and couldn't resolve any seed nodes")
|
||||||
}
|
}
|
||||||
|
|
||||||
r.seedAddrs = seedAddrs
|
r.seedAddrs = seedAddrs
|
||||||
@ -573,7 +573,7 @@ func (r *PEXReactor) checkSeeds() (numOnline int, netAddrs []*p2p.NetAddress, er
|
|||||||
return 0, nil, errors.Wrap(e, "seed node configuration has error")
|
return 0, nil, errors.Wrap(e, "seed node configuration has error")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return numOnline, netAddrs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// randomly dial seeds until we connect to one or exhaust them
|
// randomly dial seeds until we connect to one or exhaust them
|
||||||
@ -608,8 +608,13 @@ func (r *PEXReactor) AttemptsToDial(addr *p2p.NetAddress) int {
|
|||||||
// Seed/Crawler Mode causes this node to quickly disconnect
|
// Seed/Crawler Mode causes this node to quickly disconnect
|
||||||
// from peers, except other seed nodes.
|
// from peers, except other seed nodes.
|
||||||
func (r *PEXReactor) crawlPeersRoutine() {
|
func (r *PEXReactor) crawlPeersRoutine() {
|
||||||
// Do an initial crawl
|
// If we have any seed nodes, consult them first
|
||||||
r.crawlPeers(r.book.GetSelection())
|
if len(r.seedAddrs) > 0 {
|
||||||
|
r.dialSeeds()
|
||||||
|
} else {
|
||||||
|
// Do an initial crawl
|
||||||
|
r.crawlPeers(r.book.GetSelection())
|
||||||
|
}
|
||||||
|
|
||||||
// Fire periodically
|
// Fire periodically
|
||||||
ticker := time.NewTicker(crawlPeerPeriod)
|
ticker := time.NewTicker(crawlPeerPeriod)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user