diff options
author | obscuren <geffobscura@gmail.com> | 2014-06-23 17:24:45 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-06-23 17:24:45 +0800 |
commit | 9350ecd36fe3a30bea4cfd60db9a53787d4d5852 (patch) | |
tree | b43ffe7ee2e3d4ee95626a669dc04afaf47ea6b7 /peer.go | |
parent | 8c96c5662f9a362c50f3e6e04e886e2518cc68b9 (diff) | |
download | go-tangerine-9350ecd36fe3a30bea4cfd60db9a53787d4d5852.tar go-tangerine-9350ecd36fe3a30bea4cfd60db9a53787d4d5852.tar.gz go-tangerine-9350ecd36fe3a30bea4cfd60db9a53787d4d5852.tar.bz2 go-tangerine-9350ecd36fe3a30bea4cfd60db9a53787d4d5852.tar.lz go-tangerine-9350ecd36fe3a30bea4cfd60db9a53787d4d5852.tar.xz go-tangerine-9350ecd36fe3a30bea4cfd60db9a53787d4d5852.tar.zst go-tangerine-9350ecd36fe3a30bea4cfd60db9a53787d4d5852.zip |
Do not keep on asking for the same chain
Diffstat (limited to 'peer.go')
-rw-r--r-- | peer.go | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -138,6 +138,8 @@ type Peer struct { // We use this to give some kind of pingtime to a node, not very accurate, could be improved. pingTime time.Duration pingStartTime time.Time + + lastRequestedBlock *ethchain.Block } func NewPeer(conn net.Conn, ethereum *Ethereum, inbound bool) *Peer { @@ -351,6 +353,12 @@ func (p *Peer) HandleInbound() { // We requested blocks and now we need to make sure we have a common ancestor somewhere in these blocks so we can find // common ground to start syncing from lastBlock = ethchain.NewBlockFromRlpValue(msg.Data.Get(msg.Data.Len() - 1)) + if p.lastRequestedBlock != nil && bytes.Compare(lastBlock.Hash(), p.lastRequestedBlock.Hash()) == 0 { + p.catchingUp = false + continue + } + p.lastRequestedBlock = lastBlock + ethutil.Config.Log.Infof("[PEER] Last block: %x. Checking if we have it locally.\n", lastBlock.Hash()) for i := msg.Data.Len() - 1; i >= 0; i-- { block = ethchain.NewBlockFromRlpValue(msg.Data.Get(i)) |