Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions eth/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,20 @@ func (cs *chainSyncer) nextSyncOp() *chainSyncOp {
// cs.handler.acceptTxs.Store(false)
// log.Info("Disable transaction acceptance randomly for the delay exceeding 10 blocks.")
// }
} else if op.td.Cmp(new(big.Int).Add(ourTD, common.Big2)) <= 0 { // common.Big2: difficulty of an in-turn block
// On BSC, blocks are produced much faster than on Ethereum.
// If the node is only slightly behind (e.g., 1 block), syncing is unnecessary.
// It's likely still processing broadcasted blocks or block hash announcements.
// In most cases, the node will catch up within 3 seconds.
time.Sleep(3 * time.Second)

// Re-check local head to see if it has caught up
if _, latestTD := cs.modeAndLocalHead(); ourTD.Cmp(latestTD) < 0 {
log.Trace("The local head is already caught up; synchronization is not required.")
return nil
}
}

return op
}

Expand Down