Skip to content

handler.doSync

Source (upstream pre-purge) Current
File eth/sync.go sync_pow.go
Symbol handler.doSync handler.doSync
Ref f4d53133f~1 etc/v1.17.3-full-node

3-way merge — purge → getc ← upstream

pre-purge≈ adapted (origin inferred by similarity)
// doSync synchronizes the local blockchain with a remote peer.
func (h *handler) doSync(op *chainSyncOp) error {
// Run the sync cycle, and disable snap sync if we're past the pivot block
err := h.downloader.LegacySync(op.peer.ID(), op.head, op.td, op.mode)
if err != nil {
return err
}
h.enableSyncedFeatures()
head := h.chain.CurrentBlock()
if head.Number.Uint64() > 0 {
// We've completed a sync cycle, notify all peers of new state. This path is
// essential in star-topology networks where a gateway node needs to notify
// all its out-of-date peers of the availability of a new block. This failure
// scenario will most often crop up in private and hackathon networks with
// degenerate connectivity, but it should be healthy for the mainnet too to
// more reliably update peers or the local TD state.
if block := h.chain.GetBlock(head.Hash(), head.Number.Uint64()); block != nil {
h.BroadcastBlock(block, false)
}
}
return nil
}
core-geth validation — +1 -8 | | | |---|---| | File | [`sync.go`](https://github.com/etclabscore/core-geth/blob/v1.12.20/eth/sync.go) | | Symbol | `handler.doSync` | | Ref | `v1.12.20` |
--- a/core-geth/eth/sync.go
+++ b/etc/eth/sync_pow.go
@@ -1,20 +1,13 @@
 // doSync synchronizes the local blockchain with a remote peer.
 func (h *handler) doSync(op *chainSyncOp) error {
    // Run the sync cycle, and disable snap sync if we're past the pivot block
-   err := h.downloader.LegacySync(op.peer.ID(), op.head, op.td, h.chain.Config().GetEthashTerminalTotalDifficulty(), op.mode)
+   err := h.downloader.LegacySync(op.peer.ID(), op.head, op.td, op.mode)
    if err != nil {
        return err
    }
    h.enableSyncedFeatures()

    head := h.chain.CurrentBlock()
-   if head.Number.Uint64() >= h.checkpointNumber {
-       // Checkpoint passed, sanity check the timestamp to have a fallback mechanism
-       // for non-checkpointed (number = 0) private networks.
-       if head.Time >= uint64(time.Now().AddDate(0, -1, 0).Unix()) {
-           h.synced.Store(true)
-       }
-   }
    if head.Number.Uint64() > 0 {
        // We've completed a sync cycle, notify all peers of new state. This path is
        // essential in star-topology networks where a gateway node needs to notify

← Sync & Downloader