diff options
author | zelig <viktor.tron@gmail.com> | 2014-06-23 20:07:43 +0800 |
---|---|---|
committer | zelig <viktor.tron@gmail.com> | 2014-06-23 20:07:43 +0800 |
commit | f58c7ac5a6f5d77649c1c07dce94bf6d5c146c31 (patch) | |
tree | 31e286974108e02b29ed5eff0a73646f605998c2 /peer.go | |
parent | 63157c798d613f1ca638597515bb89768e2c1aad (diff) | |
parent | d890258af6de8c5ef9701826fb4ee7c353788ad5 (diff) | |
download | go-tangerine-f58c7ac5a6f5d77649c1c07dce94bf6d5c146c31.tar go-tangerine-f58c7ac5a6f5d77649c1c07dce94bf6d5c146c31.tar.gz go-tangerine-f58c7ac5a6f5d77649c1c07dce94bf6d5c146c31.tar.bz2 go-tangerine-f58c7ac5a6f5d77649c1c07dce94bf6d5c146c31.tar.lz go-tangerine-f58c7ac5a6f5d77649c1c07dce94bf6d5c146c31.tar.xz go-tangerine-f58c7ac5a6f5d77649c1c07dce94bf6d5c146c31.tar.zst go-tangerine-f58c7ac5a6f5d77649c1c07dce94bf6d5c146c31.zip |
merge upstream
Diffstat (limited to 'peer.go')
-rw-r--r-- | peer.go | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -141,6 +141,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 { @@ -354,6 +356,11 @@ 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 peerlogger.Infof("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)) |