forked from TrueCloudLab/neoneo-go
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.
This commit is contained in:
parent
2348a460ea
commit
247cfa4165
1 changed files with 4 additions and 5 deletions
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue