Browse Source

minor fixes

pull/1519/head
Ethan Buchman 7 years ago
parent
commit
3a30ee75b9
2 changed files with 7 additions and 9 deletions
  1. +6
    -6
      docs/specification/new-spec/reactors/pex/pex.md
  2. +1
    -3
      p2p/pex/addrbook.go

+ 6
- 6
docs/specification/new-spec/reactors/pex/pex.md View File

@ -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 -
MinNumOutboundPeers) incoming peers.
## Address Book
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
when we hear about them from other peers.
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
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
dial 3 times, and then remove them from only that bucket.
If we're trying to add a new peer but there's no space in its bucket, we'll
remove the worst peer from that bucket to make room.
## Vetting


+ 1
- 3
p2p/pex/addrbook.go View File

@ -496,7 +496,7 @@ func (a *addrBook) getBucket(bucketType byte, bucketIdx int) map[string]*knownAd
func (a *addrBook) addToNewBucket(ka *knownAddress, bucketIdx int) {
// Sanity check
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
}
@ -679,8 +679,6 @@ func (a *addrBook) moveToOld(ka *knownAddress) {
return
}
// Remember one of the buckets in which ka is in.
freedBucket := ka.Buckets[0]
// Remove from all (new) buckets.
a.removeFromAllBuckets(ka)
// It's officially old now.


Loading…
Cancel
Save