mirror of
https://github.com/tendermint/tendermint.git
synced 2026-05-13 10:41:30 +00:00
fixes from review
This commit is contained in:
@@ -20,9 +20,9 @@ Peer discovery begins with a list of seeds.
|
||||
When we have no peers, or have been unable to find enough peers from existing ones,
|
||||
we dial a randomly selected seed to get a list of peers to dial.
|
||||
|
||||
On startup, we will also immediately dial the given list of `persisten_peers`,
|
||||
and will attempt to maintain persistent connections with them. If the connections die, or we fail to dail,
|
||||
we will redial every 5s for a a few minutes, then switch to an exponential backoff schedule,
|
||||
On startup, we will also immediately dial the given list of `persistent_peers`,
|
||||
and will attempt to maintain persistent connections with them. If the connections die, or we fail to dial,
|
||||
we will redial every 5s for a few minutes, then switch to an exponential backoff schedule,
|
||||
and after about a day of trying, stop dialing the peer.
|
||||
|
||||
So long as we have less than `MinNumOutboundPeers`, we periodically request additional peers
|
||||
@@ -84,7 +84,7 @@ Connection attempts are made with exponential backoff (plus jitter). Because
|
||||
the selection process happens every `ensurePeersPeriod`, we might not end up
|
||||
dialing a peer for much longer than the backoff duration.
|
||||
|
||||
If we fail to conenct to the peer after 16 tries (with exponential backoff), we remove from address book completely.
|
||||
If we fail to connect to the peer after 16 tries (with exponential backoff), we remove from address book completely.
|
||||
|
||||
## Select Peers to Exchange
|
||||
|
||||
|
||||
@@ -221,7 +221,11 @@ func (a *addrBook) PickAddress(biasTowardsNewAddrs int) *p2p.NetAddress {
|
||||
a.mtx.Lock()
|
||||
defer a.mtx.Unlock()
|
||||
|
||||
if a.size() == 0 {
|
||||
bookSize := a.size()
|
||||
if bookSize <= 0 {
|
||||
if bookSize < 0 {
|
||||
a.Logger.Error("Addrbook size less than 0", "nNew", a.nNew, "nOld", a.nOld)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if biasTowardsNewAddrs > 100 {
|
||||
@@ -301,7 +305,10 @@ func (a *addrBook) GetSelection() []*p2p.NetAddress {
|
||||
defer a.mtx.Unlock()
|
||||
|
||||
bookSize := a.size()
|
||||
if bookSize == 0 {
|
||||
if bookSize <= 0 {
|
||||
if bookSize < 0 {
|
||||
a.Logger.Error("Addrbook size less than 0", "nNew", a.nNew, "nOld", a.nOld)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -344,7 +351,10 @@ func (a *addrBook) GetSelectionWithBias(biasTowardsNewAddrs int) []*p2p.NetAddre
|
||||
defer a.mtx.Unlock()
|
||||
|
||||
bookSize := a.size()
|
||||
if bookSize == 0 {
|
||||
if bookSize <= 0 {
|
||||
if bookSize < 0 {
|
||||
a.Logger.Error("Addrbook size less than 0", "nNew", a.nNew, "nOld", a.nOld)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -609,10 +619,7 @@ func (a *addrBook) pickOldest(bucketType byte, bucketIdx int) *knownAddress {
|
||||
// adds the address to a "new" bucket. if its already in one,
|
||||
// it only adds it probabilistically
|
||||
func (a *addrBook) addAddress(addr, src *p2p.NetAddress) error {
|
||||
if addr == nil {
|
||||
return ErrAddrBookNilAddr{addr, src}
|
||||
}
|
||||
if src == nil {
|
||||
if addr == nil || src == nil {
|
||||
return ErrAddrBookNilAddr{addr, src}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user