@@ -30,6 +30,7 @@ import (
3030 "github.com/ethereum/go-ethereum/core/rawdb"
3131 "github.com/ethereum/go-ethereum/core/state/snapshot"
3232 "github.com/ethereum/go-ethereum/core/types"
33+ "github.com/ethereum/go-ethereum/eth/ethconfig"
3334 "github.com/ethereum/go-ethereum/eth/protocols/snap"
3435 "github.com/ethereum/go-ethereum/ethdb"
3536 "github.com/ethereum/go-ethereum/event"
6970 errNoPivotHeader = errors .New ("pivot header is not found" )
7071)
7172
73+ // SyncMode defines the sync method of the downloader.
74+ // Deprecated: use ethconfig.SyncMode instead
75+ type SyncMode = ethconfig.SyncMode
76+
77+ const (
78+ // Deprecated: use ethconfig.FullSync
79+ FullSync = ethconfig .FullSync
80+ // Deprecated: use ethconfig.SnapSync
81+ SnapSync = ethconfig .SnapSync
82+ )
83+
7284// peerDropFn is a callback type for dropping a peer detected as malicious.
7385type peerDropFn func (id string )
7486
@@ -230,9 +242,9 @@ func (d *Downloader) Progress() ethereum.SyncProgress {
230242 current := uint64 (0 )
231243 mode := d .getMode ()
232244 switch mode {
233- case FullSync :
245+ case ethconfig . FullSync :
234246 current = d .blockchain .CurrentBlock ().Number .Uint64 ()
235- case SnapSync :
247+ case ethconfig . SnapSync :
236248 current = d .blockchain .CurrentSnapBlock ().Number .Uint64 ()
237249 default :
238250 log .Error ("Unknown downloader mode" , "mode" , mode )
@@ -326,7 +338,7 @@ func (d *Downloader) synchronise(mode SyncMode, beaconPing chan struct{}) error
326338 if d .notified .CompareAndSwap (false , true ) {
327339 log .Info ("Block synchronisation started" )
328340 }
329- if mode == SnapSync {
341+ if mode == ethconfig . SnapSync {
330342 // Snap sync will directly modify the persistent state, making the entire
331343 // trie database unusable until the state is fully synced. To prevent any
332344 // subsequent state reads, explicitly disable the trie database and state
@@ -434,7 +446,7 @@ func (d *Downloader) syncToHead() (err error) {
434446 // threshold (i.e. new chain). In that case we won't really snap sync
435447 // anyway, but still need a valid pivot block to avoid some code hitting
436448 // nil panics on access.
437- if mode == SnapSync && pivot == nil {
449+ if mode == ethconfig . SnapSync && pivot == nil {
438450 pivot = d .blockchain .CurrentBlock ()
439451 }
440452 height := latest .Number .Uint64 ()
@@ -452,7 +464,7 @@ func (d *Downloader) syncToHead() (err error) {
452464 d .syncStatsLock .Unlock ()
453465
454466 // Ensure our origin point is below any snap sync pivot point
455- if mode == SnapSync {
467+ if mode == ethconfig . SnapSync {
456468 if height <= uint64 (fsMinFullBlocks ) {
457469 origin = 0
458470 } else {
@@ -466,10 +478,10 @@ func (d *Downloader) syncToHead() (err error) {
466478 }
467479 }
468480 d .committed .Store (true )
469- if mode == SnapSync && pivot .Number .Uint64 () != 0 {
481+ if mode == ethconfig . SnapSync && pivot .Number .Uint64 () != 0 {
470482 d .committed .Store (false )
471483 }
472- if mode == SnapSync {
484+ if mode == ethconfig . SnapSync {
473485 // Set the ancient data limitation. If we are running snap sync, all block
474486 // data older than ancientLimit will be written to the ancient store. More
475487 // recent data will be written to the active database and will wait for the
@@ -523,13 +535,13 @@ func (d *Downloader) syncToHead() (err error) {
523535 func () error { return d .fetchReceipts (origin + 1 ) }, // Receipts are retrieved during snap sync
524536 func () error { return d .processHeaders (origin + 1 ) },
525537 }
526- if mode == SnapSync {
538+ if mode == ethconfig . SnapSync {
527539 d .pivotLock .Lock ()
528540 d .pivotHeader = pivot
529541 d .pivotLock .Unlock ()
530542
531543 fetchers = append (fetchers , func () error { return d .processSnapSyncContent () })
532- } else if mode == FullSync {
544+ } else if mode == ethconfig . FullSync {
533545 fetchers = append (fetchers , func () error { return d .processFullSyncContent () })
534546 }
535547 return d .spawnSync (fetchers )
@@ -676,7 +688,7 @@ func (d *Downloader) processHeaders(origin uint64) error {
676688 chunkHashes := hashes [:limit ]
677689
678690 // In case of header only syncing, validate the chunk immediately
679- if mode == SnapSync {
691+ if mode == ethconfig . SnapSync {
680692 // Although the received headers might be all valid, a legacy
681693 // PoW/PoA sync must not accept post-merge headers. Make sure
682694 // that any transition is rejected at this point.
0 commit comments