mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-12 04:41:22 +00:00
minor fixes
This commit is contained in:
@ -35,22 +35,22 @@ Peers listen on a configurable ListenAddr that they self-report in their
|
|||||||
NodeInfo during handshakes with other peers. Peers accept up to (MaxNumPeers -
|
NodeInfo during handshakes with other peers. Peers accept up to (MaxNumPeers -
|
||||||
MinNumOutboundPeers) incoming peers.
|
MinNumOutboundPeers) incoming peers.
|
||||||
|
|
||||||
|
|
||||||
## Address Book
|
## Address Book
|
||||||
|
|
||||||
Peers are tracked via their ID (their PubKey.Address()).
|
Peers are tracked via their ID (their PubKey.Address()).
|
||||||
For each ID, the address book keeps the most recent IP:PORT.
|
|
||||||
Peers are added to the address book from the PEX when they first connect to us or
|
Peers are added to the address book from the PEX when they first connect to us or
|
||||||
when we hear about them from other peers.
|
when we hear about them from other peers.
|
||||||
|
|
||||||
The address book is arranged in sets of buckets, and distinguishes between
|
The address book is arranged in sets of buckets, and distinguishes between
|
||||||
vetted (old) and unvetted (new) peers. It keeps different sets of buckets for vetted and
|
vetted (old) and unvetted (new) peers. It keeps different sets of buckets for vetted and
|
||||||
unvetted peers. Buckets provide randomization over peer selection.
|
unvetted peers. Buckets provide randomization over peer selection. Peers are put
|
||||||
|
in buckets according to their IP groups.
|
||||||
|
|
||||||
A vetted peer can only be in one bucket. An unvetted peer can be in multiple buckets.
|
A vetted peer can only be in one bucket. An unvetted peer can be in multiple buckets, and
|
||||||
|
each instance of the peer can have a different IP:PORT.
|
||||||
|
|
||||||
If there's no space in the book, we check the bucket for bad peers, which include peers we've attempted to
|
If we're trying to add a new peer but there's no space in its bucket, we'll
|
||||||
dial 3 times, and then remove them from only that bucket.
|
remove the worst peer from that bucket to make room.
|
||||||
|
|
||||||
## Vetting
|
## Vetting
|
||||||
|
|
||||||
|
@ -496,7 +496,7 @@ func (a *addrBook) getBucket(bucketType byte, bucketIdx int) map[string]*knownAd
|
|||||||
func (a *addrBook) addToNewBucket(ka *knownAddress, bucketIdx int) {
|
func (a *addrBook) addToNewBucket(ka *knownAddress, bucketIdx int) {
|
||||||
// Sanity check
|
// Sanity check
|
||||||
if ka.isOld() {
|
if ka.isOld() {
|
||||||
a.Logger.Error("Failed Sanity Check! Cant add old address to new bucket", "ka", knownAddress, "bucket", bucketIdx)
|
a.Logger.Error("Failed Sanity Check! Cant add old address to new bucket", "ka", ka, "bucket", bucketIdx)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -679,8 +679,6 @@ func (a *addrBook) moveToOld(ka *knownAddress) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remember one of the buckets in which ka is in.
|
|
||||||
freedBucket := ka.Buckets[0]
|
|
||||||
// Remove from all (new) buckets.
|
// Remove from all (new) buckets.
|
||||||
a.removeFromAllBuckets(ka)
|
a.removeFromAllBuckets(ka)
|
||||||
// It's officially old now.
|
// It's officially old now.
|
||||||
|
Reference in New Issue
Block a user