diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-04-17 17:32:55 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-04-17 17:32:55 +0800 |
commit | d3ed3285e942e312ef2ded2671a09e717e97f33f (patch) | |
tree | 43f4052375c5b4749a65ee52acce8a76b84e340d | |
parent | 545ff1e3f3d76202696f60336335536a083e610e (diff) | |
parent | 5528abc79588d15aa795a6e9b0050ff3e7616ed2 (diff) | |
download | go-tangerine-d3ed3285e942e312ef2ded2671a09e717e97f33f.tar.gz go-tangerine-d3ed3285e942e312ef2ded2671a09e717e97f33f.tar.zst go-tangerine-d3ed3285e942e312ef2ded2671a09e717e97f33f.zip |
Merge pull request #733 from fjl/p2p-dial-timer
p2p: fix the dial timer
-rw-r--r-- | p2p/server.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/p2p/server.go b/p2p/server.go index eaffc9d13..b5c4a1f59 100644 --- a/p2p/server.go +++ b/p2p/server.go @@ -359,9 +359,11 @@ func (srv *Server) dialLoop() { rand.Read(target[:]) findresults <- srv.ntab.Lookup(target) }() - refresh.Stop() + } else { + // Make sure we check again if the peer count falls + // below MaxPeers. + refresh.Reset(refreshPeersInterval) } - case dest := <-srv.peerConnect: dial(dest) case dests := <-findresults: @@ -371,7 +373,10 @@ func (srv *Server) dialLoop() { refresh.Reset(refreshPeersInterval) case dest := <-dialed: delete(dialing, dest.ID) - + if len(dialing) == 0 { + // Check again immediately after dialing all current candidates. + refresh.Reset(0) + } case <-srv.quit: // TODO: maybe wait for active dials return |