Skip to content

Commit 382d35b

Browse files
committed
Merge pull request #1688 from karalabe/fix-double-imports
eth: fix an issue with pulling and inserting blocks twice
2 parents c6a11fe + 941920f commit 382d35b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

eth/handler.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,12 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
413413

414414
pm.fetcher.Enqueue(p.id, request.Block)
415415

416-
// TODO: Schedule a sync to cover potential gaps (this needs proto update)
416+
// Update the peers total difficulty if needed, schedule a download if gapped
417417
if request.TD.Cmp(p.Td()) > 0 {
418418
p.SetTd(request.TD)
419-
go pm.synchronise(p)
419+
if request.TD.Cmp(new(big.Int).Add(pm.chainman.Td(), request.Block.Difficulty())) > 0 {
420+
go pm.synchronise(p)
421+
}
420422
}
421423

422424
case TxMsg:

0 commit comments

Comments
 (0)