chainSyncer.loop¶
| Source (upstream pre-purge) | Current | |
|---|---|---|
| File | eth/sync.go |
sync_pow.go |
| Symbol | chainSyncer.loop |
chainSyncer.loop |
| Ref | f4d53133f~1 |
etc/v1.17.3-full-node |
StopInsert → InterruptInsert(true) per #32067
3-way merge — purge → getc ← upstream¶
pre-purge≈ adapted (origin inferred by similarity)fork-only
↗// loop runs in its own goroutine and launches the sync when necessary.
func (cs *chainSyncer) loop() {
defer cs.handler.wg.Done()
↗ cs.handler.blockFetcher.Start()
cs.handler.txFetcher.Start()
defer cs.handler.blockFetcher.Stop()
defer cs.handler.txFetcher.Stop()
defer cs.handler.downloader.Terminate()
↗ // The force timer lowers the peer count threshold down to one when it fires.
// This ensures we'll always start sync even if there aren't enough peers.
cs.force = time.NewTimer(forceSyncCycle)
defer cs.force.Stop()
↗ for {
if op := cs.nextSyncOp(); op != nil {
cs.startSync(op)
}
select {
case <-cs.peerEventCh:
// Peer information changed, recheck.
case err := <-cs.doneCh:
cs.doneCh = nil
cs.force.Reset(forceSyncCycle)
cs.forced = false
// If sync completed successfully, check MESS activation
if err == nil {
cs.checkMESSActivation()
↗ }
↗ case <-cs.force.C:
cs.forced = true
↗ case <-cs.handler.quitSync:
// Disable all insertion on the blockchain. This needs to happen before
// terminating the downloader because the downloader waits for blockchain
// inserts, and these can take a long time to finish.
≈ cs.handler.chain.InterruptInsert(true)
↗ cs.handler.downloader.Terminate()
if cs.doneCh != nil {
<-cs.doneCh
}
return
}
}
}
core-geth validation — +5 -7
| | | |---|---| | File | [`sync.go`](https://github.com/etclabscore/core-geth/blob/v1.12.20/eth/sync.go) | | Symbol | `chainSyncer.loop` | | Ref | `v1.12.20` |--- a/core-geth/eth/sync.go
+++ b/etc/eth/sync_pow.go
@@ -25,13 +25,11 @@
cs.force.Reset(forceSyncCycle)
cs.forced = false
- // If we've reached the merge transition but no beacon client is available, or
- // it has not yet switched us over, keep warning the user that their infra is
- // potentially flaky.
- if errors.Is(err, downloader.ErrMergeTransition) && time.Since(cs.warned) > 10*time.Second {
- log.Warn("Local chain is post-merge, waiting for beacon client sync switch-over...")
- cs.warned = time.Now()
+ // If sync completed successfully, check MESS activation
+ if err == nil {
+ cs.checkMESSActivation()
}
+
case <-cs.force.C:
cs.forced = true
@@ -39,7 +37,7 @@
// Disable all insertion on the blockchain. This needs to happen before
// terminating the downloader because the downloader waits for blockchain
// inserts, and these can take a long time to finish.
- cs.handler.chain.StopInsert()
+ cs.handler.chain.InterruptInsert(true)
cs.handler.downloader.Terminate()
if cs.doneCh != nil {
<-cs.doneCh