aboutsummaryrefslogtreecommitdiffstats
path: root/p2p
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-04-17 09:52:54 +0800
committerFelix Lange <fjl@twurst.com>2015-04-17 14:17:01 +0800
commit5528abc79588d15aa795a6e9b0050ff3e7616ed2 (patch)
tree43f4052375c5b4749a65ee52acce8a76b84e340d /p2p
parent545ff1e3f3d76202696f60336335536a083e610e (diff)
downloaddexon-5528abc79588d15aa795a6e9b0050ff3e7616ed2.tar
dexon-5528abc79588d15aa795a6e9b0050ff3e7616ed2.tar.gz
dexon-5528abc79588d15aa795a6e9b0050ff3e7616ed2.tar.bz2
dexon-5528abc79588d15aa795a6e9b0050ff3e7616ed2.tar.lz
dexon-5528abc79588d15aa795a6e9b0050ff3e7616ed2.tar.xz
dexon-5528abc79588d15aa795a6e9b0050ff3e7616ed2.tar.zst
dexon-5528abc79588d15aa795a6e9b0050ff3e7616ed2.zip
p2p: fix the dial timer
The dial timer was not reset properly when the peer count reached MaxPeers.
Diffstat (limited to 'p2p')
-rw-r--r--p2p/server.go11
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