From 941920f2aa651abc6bd72deda09f62d77aeaa2bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Wed, 19 Aug 2015 15:14:26 +0300 Subject: [PATCH] eth: fix an issue with pulling and inserting blocks twice --- eth/handler.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/eth/handler.go b/eth/handler.go index 2bd3699013..5d233dd968 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -413,10 +413,12 @@ func (pm *ProtocolManager) handleMsg(p *peer) error { pm.fetcher.Enqueue(p.id, request.Block) - // TODO: Schedule a sync to cover potential gaps (this needs proto update) + // Update the peers total difficulty if needed, schedule a download if gapped if request.TD.Cmp(p.Td()) > 0 { p.SetTd(request.TD) - go pm.synchronise(p) + if request.TD.Cmp(new(big.Int).Add(pm.chainman.Td(), request.Block.Difficulty())) > 0 { + go pm.synchronise(p) + } } case TxMsg: