diff --git a/p2p/pex/addrbook.go b/p2p/pex/addrbook.go index 7a6104d504..ab12a5f049 100644 --- a/p2p/pex/addrbook.go +++ b/p2p/pex/addrbook.go @@ -79,8 +79,6 @@ type AddrBook interface { // Persist to disk Save() - - LoadDialAttempts(*Reactor) bool } var _ AddrBook = (*addrBook)(nil) @@ -958,10 +956,3 @@ func (a *addrBook) hash(b []byte) ([]byte, error) { hasher.Write(b) return hasher.Sum(nil), nil } - -func (a *addrBook) LoadDialAttempts(r *Reactor) bool { - a.mtx.Lock() - defer a.mtx.Unlock() - - return a.loadDialAttempts(a.filePath, r) -} diff --git a/p2p/pex/file.go b/p2p/pex/file.go index 2dda335aab..38eec9636b 100644 --- a/p2p/pex/file.go +++ b/p2p/pex/file.go @@ -81,38 +81,3 @@ func (a *addrBook) loadFromFile(filePath string) bool { } return true } - -func (a *addrBook) loadDialAttempts(filePath string, r *Reactor) bool { - // If doesn't exist, do nothing. - _, err := os.Stat(filePath) - if os.IsNotExist(err) { - return false - } - - // Load addrBookJSON{} - addrBook, err := os.Open(filePath) - if err != nil { - panic(fmt.Sprintf("Error opening file %s: %v", filePath, err)) - } - defer addrBook.Close() - aJSON := &addrBookJSON{} - dec := json.NewDecoder(addrBook) - err = dec.Decode(aJSON) - if err != nil { - panic(fmt.Sprintf("Error reading file %s: %v", filePath, err)) - } - - // Restore all the fields... - // Restore the key - a.key = aJSON.Key - // Restore .bucketsNew & .bucketsOld - for _, ka := range aJSON.Addrs { - // Populate attemptsToDial in Reactor - r.attemptsToDial.Store(ka.Addr.String(), _attemptsToDial{ - number: int(ka.Attempts), - lastDialed: ka.LastAttempt, - }) - } - - return true -} diff --git a/p2p/pex/pex_reactor.go b/p2p/pex/pex_reactor.go index b23e08058c..eb959113c4 100644 --- a/p2p/pex/pex_reactor.go +++ b/p2p/pex/pex_reactor.go @@ -157,8 +157,6 @@ func (r *Reactor) OnStart() error { r.seedAddrs = seedAddrs - r.book.LoadDialAttempts(r) - // Check if this node should run // in seed/crawler mode if r.config.SeedMode { @@ -830,7 +828,6 @@ func (r *Reactor) attemptDisconnects() { func markAddrInBookBasedOnErr(addr *p2p.NetAddress, book AddrBook, err error) { // TODO: detect more "bad peer" scenarios // TODO, blacklist peer if fmt.Errorf("peer is on a different network. Got %v, expected %v", other.Network, info.Network) - // TODO, connect: no route to host block switch err.(type) { case p2p.ErrSwitchAuthenticationFailure: book.MarkBad(addr, defaultBanTime)