From 247cfa416531e896938233ff6f07e4fbacbc6d12 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Mon, 20 Jan 2020 16:58:28 +0300 Subject: [PATCH] network: either request blocks or ping a peer, but not both It makes to sense to do both actions, pings are made for a different purpose. Relates to #430. --- pkg/network/tcp_peer.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/network/tcp_peer.go b/pkg/network/tcp_peer.go index 62ceb417d..8c56f9d45 100644 --- a/pkg/network/tcp_peer.go +++ b/pkg/network/tcp_peer.go @@ -207,11 +207,7 @@ func (p *TCPPeer) StartProtocol() { // Try to sync in headers and block with the peer if his block height is higher then ours. if p.LastBlockIndex() > p.server.chain.BlockHeight() { err = p.server.requestBlocks(p) - } - if err == nil { - timer.Reset(p.server.ProtoTickInterval) - } - if p.server.chain.HeaderHeight() >= p.LastBlockIndex() { + } else if p.server.chain.HeaderHeight() >= p.LastBlockIndex() { block, errGetBlock := p.server.chain.GetBlock(p.server.chain.CurrentBlockHash()) if errGetBlock != nil { err = errGetBlock @@ -223,6 +219,9 @@ func (p *TCPPeer) StartProtocol() { } } } + if err == nil { + timer.Reset(p.server.ProtoTickInterval) + } case <-pingTimer.C: if p.GetPingSent() > defaultPingLimit { err = errors.New("ping/pong timeout")