diff options
author | Martin Holst Swende <martin@swende.se> | 2017-09-04 15:24:52 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2017-09-04 15:24:52 +0800 |
commit | dc92779c0a1e01de9561087a3a534d9d7cfdef3f (patch) | |
tree | 1ff24336c36d4df8024c63c5340dbd2c663cfa2a /p2p | |
parent | d70536b5d4e8580a39a9887ce58c4a21c74344ee (diff) | |
download | dexon-dc92779c0a1e01de9561087a3a534d9d7cfdef3f.tar dexon-dc92779c0a1e01de9561087a3a534d9d7cfdef3f.tar.gz dexon-dc92779c0a1e01de9561087a3a534d9d7cfdef3f.tar.bz2 dexon-dc92779c0a1e01de9561087a3a534d9d7cfdef3f.tar.lz dexon-dc92779c0a1e01de9561087a3a534d9d7cfdef3f.tar.xz dexon-dc92779c0a1e01de9561087a3a534d9d7cfdef3f.tar.zst dexon-dc92779c0a1e01de9561087a3a534d9d7cfdef3f.zip |
p2p: change ping ticker to timer (#15071)
Using a Timer over Ticker seems to be a lot better, though I cannot fully
account for why that it behaves so (since Ticker should be more bursty, but not
necessarily more active over time, but that may depend on how long window it
uses to decide on when to tick next)
Diffstat (limited to 'p2p')
-rw-r--r-- | p2p/peer.go | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/p2p/peer.go b/p2p/peer.go index a9c20189a..fb4b39e95 100644 --- a/p2p/peer.go +++ b/p2p/peer.go @@ -190,7 +190,7 @@ loop: } func (p *Peer) pingLoop() { - ping := time.NewTicker(pingInterval) + ping := time.NewTimer(pingInterval) defer p.wg.Done() defer ping.Stop() for { @@ -200,6 +200,7 @@ func (p *Peer) pingLoop() { p.protoErr <- err return } + ping.Reset(pingInterval) case <-p.closed: return } |