Skip to content

Commit dc6e98d

Browse files
committed
eth: when triggering a sync, check the head header TD, not block
1 parent 5dd0cd1 commit dc6e98d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

eth/handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,8 +727,8 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
727727
// Schedule a sync if above ours. Note, this will not fire a sync for a gap of
728728
// a single block (as the true TD is below the propagated block), however this
729729
// scenario should easily be covered by the fetcher.
730-
currentBlock := pm.blockchain.CurrentBlock()
731-
if trueTD.Cmp(pm.blockchain.GetTd(currentBlock.Hash(), currentBlock.NumberU64())) > 0 {
730+
currentHeader := pm.blockchain.CurrentHeader()
731+
if trueTD.Cmp(pm.blockchain.GetTd(currentHeader.Hash(), currentHeader.Number.Uint64())) > 0 {
732732
go pm.synchronise(p)
733733
}
734734
}

eth/sync.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ func (pm *ProtocolManager) synchronise(peer *peer) {
189189
return
190190
}
191191
// Make sure the peer's TD is higher than our own
192-
currentBlock := pm.blockchain.CurrentBlock()
193-
td := pm.blockchain.GetTd(currentBlock.Hash(), currentBlock.NumberU64())
192+
currentHeader := pm.blockchain.CurrentHeader()
193+
td := pm.blockchain.GetTd(currentHeader.Hash(), currentHeader.Number.Uint64())
194194

195195
pHead, pTd := peer.Head()
196196
if pTd.Cmp(td) <= 0 {

0 commit comments

Comments
 (0)