Browse Source

move reinstatement after if statement in pex reactor

pull/4548/head
Callum Michael Waters 5 years ago
parent
commit
6ccd3324c2
2 changed files with 6 additions and 3 deletions
  1. +3
    -2
      p2p/pex/addrbook.go
  2. +3
    -1
      p2p/pex/pex_reactor.go

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

@ -60,7 +60,9 @@ type AddrBook interface {
// Mark address
MarkGood(p2p.ID)
MarkAttempt(*p2p.NetAddress)
MarkBad(*p2p.NetAddress)
MarkBad(*p2p.NetAddress) // Move peer to bad peers list
// Add bad peers back to addrBook
ReinstateBadPeers()
IsGood(*p2p.NetAddress) bool
@ -236,7 +238,6 @@ func (a *addrBook) HasAddress(addr *p2p.NetAddress) bool {
// NeedMoreAddrs implements AddrBook - returns true if there are not have enough addresses in the book.
func (a *addrBook) NeedMoreAddrs() bool {
a.ReinstateBadPeers()
return a.Size() < needAddressThreshold
}


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

@ -8,7 +8,7 @@ import (
"github.com/pkg/errors"
amino "github.com/tendermint/go-amino"
"github.com/tendermint/go-amino"
"github.com/tendermint/tendermint/libs/cmap"
tmmath "github.com/tendermint/tendermint/libs/math"
"github.com/tendermint/tendermint/libs/rand"
@ -494,6 +494,8 @@ func (r *Reactor) ensurePeers() {
}
if r.book.NeedMoreAddrs() {
// 0) Check if banned nodes can be reinstated
r.book.ReinstateBadPeers()
// 1) Pick a random peer and ask for more.
peers := r.Switch.Peers().List()
peersCount := len(peers)


Loading…
Cancel
Save