aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-08-19 20:14:26 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-08-19 20:14:26 +0800
commit941920f2aa651abc6bd72deda09f62d77aeaa2bf (patch)
treef5205255cab1079d0b39094cd807e220eb25db47
parent3b997c3e169dc3dee8f41d9ece5341ef04d7eeaf (diff)
downloadgo-tangerine-941920f2aa651abc6bd72deda09f62d77aeaa2bf.tar
go-tangerine-941920f2aa651abc6bd72deda09f62d77aeaa2bf.tar.gz
go-tangerine-941920f2aa651abc6bd72deda09f62d77aeaa2bf.tar.bz2
go-tangerine-941920f2aa651abc6bd72deda09f62d77aeaa2bf.tar.lz
go-tangerine-941920f2aa651abc6bd72deda09f62d77aeaa2bf.tar.xz
go-tangerine-941920f2aa651abc6bd72deda09f62d77aeaa2bf.tar.zst
go-tangerine-941920f2aa651abc6bd72deda09f62d77aeaa2bf.zip
eth: fix an issue with pulling and inserting blocks twice
-rw-r--r--eth/handler.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/eth/handler.go b/eth/handler.go
index 2bd369901..5d233dd96 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: