mirror of
https://github.com/tendermint/tendermint.git
synced 2026-08-21 14:46:15 +00:00
made suggested changes
This commit is contained in:
+4
-3
@@ -222,11 +222,12 @@ func (a *addrBook) IsGood(addr *p2p.NetAddress) bool {
|
||||
return a.addrLookup[addr.ID].isOld()
|
||||
}
|
||||
|
||||
// IsBanned returns true if the peer is currently banned
|
||||
func (a *addrBook) IsBanned(addr *p2p.NetAddress) bool {
|
||||
a.mtx.Lock()
|
||||
defer a.mtx.Unlock()
|
||||
|
||||
_, ok := a.badPeers[addr.ID]
|
||||
a.mtx.Unlock()
|
||||
|
||||
return ok
|
||||
}
|
||||
|
||||
@@ -351,7 +352,7 @@ func (a *addrBook) ReinstateBadPeers() {
|
||||
bucket := a.calcNewBucket(ka.Addr, ka.Src)
|
||||
a.addToNewBucket(ka, bucket)
|
||||
delete(a.badPeers, ka.ID())
|
||||
a.Logger.Info("Reinstated Address", "addr", ka.Addr)
|
||||
a.Logger.Info("Reinstated address", "addr", ka.Addr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ func (err ErrAddrBookInvalidAddr) Error() string {
|
||||
return fmt.Sprintf("Cannot add invalid address %v: %v", err.Addr, err.AddrErr)
|
||||
}
|
||||
|
||||
// Err is thrown when the address is banned and therefore cannot be used
|
||||
type ErrAddressBanned struct {
|
||||
Addr *p2p.NetAddress
|
||||
}
|
||||
|
||||
@@ -534,10 +534,6 @@ func (r *Reactor) dialAttemptsInfo(addr *p2p.NetAddress) (attempts int, lastDial
|
||||
func (r *Reactor) dialPeer(addr *p2p.NetAddress) error {
|
||||
attempts, lastDialed := r.dialAttemptsInfo(addr)
|
||||
if !r.Switch.IsPeerPersistent(addr) && attempts > maxAttemptsToDial {
|
||||
// TODO(melekes): have a blacklist in the addrbook with peers whom we've
|
||||
// failed to connect to. Then we can clean up attemptsToDial, which acts as
|
||||
// a blacklist currently.
|
||||
// https://github.com/tendermint/tendermint/issues/3572
|
||||
r.book.MarkBad(addr, defaultBanTime)
|
||||
return errMaxAttemptsToDial{}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user