@@ -31,7 +31,6 @@ import (
3131 "github.com/ethereum/go-ethereum/core/state/snapshot"
3232 "github.com/ethereum/go-ethereum/core/types"
3333 "github.com/ethereum/go-ethereum/eth/downloader/whitelist"
34- "github.com/ethereum/go-ethereum/eth/ethconfig"
3534 "github.com/ethereum/go-ethereum/eth/protocols/snap"
3635 "github.com/ethereum/go-ethereum/ethdb"
3736 "github.com/ethereum/go-ethereum/event"
8483 ErrMergeTransition = errors .New ("legacy sync reached the merge" )
8584)
8685
87- // SyncMode defines the sync method of the downloader.
88- // Deprecated: use ethconfig.SyncMode instead
89- type SyncMode = ethconfig.SyncMode
90-
91- const (
92- // Deprecated: use ethconfig.FullSync
93- FullSync = ethconfig .FullSync
94- // Deprecated: use ethconfig.SnapSync
95- SnapSync = ethconfig .SnapSync
96- )
97-
9886// peerDropFn is a callback type for dropping a peer detected as malicious.
9987type peerDropFn func (id string )
10088
@@ -279,11 +267,10 @@ func (d *Downloader) Progress() ethereum.SyncProgress {
279267
280268 current := uint64 (0 )
281269 mode := d .getMode ()
282-
283- switch {
284- case d .blockchain != nil && mode == ethconfig .FullSync :
270+ switch mode {
271+ case FullSync :
285272 current = d .blockchain .CurrentBlock ().Number .Uint64 ()
286- case d . blockchain != nil && mode == ethconfig . SnapSync :
273+ case SnapSync :
287274 current = d .blockchain .CurrentSnapBlock ().Number .Uint64 ()
288275 case d .lightchain != nil :
289276 current = d .lightchain .CurrentHeader ().Number .Uint64 ()
@@ -431,7 +418,7 @@ func (d *Downloader) synchronise(id string, hash common.Hash, td, ttd *big.Int,
431418 if d .notified .CompareAndSwap (false , true ) {
432419 log .Info ("Block synchronisation started" )
433420 }
434- if mode == ethconfig . SnapSync {
421+ if mode == SnapSync {
435422 // Snap sync will directly modify the persistent state, making the entire
436423 // trie database unusable until the state is fully synced. To prevent any
437424 // subsequent state reads, explicitly disable the trie database and state
@@ -569,7 +556,7 @@ func (d *Downloader) syncWithPeer(p *peerConnection, hash common.Hash, td, ttd *
569556 // threshold (i.e. new chain). In that case we won't really fast sync
570557 // anyway, but still need a valid pivot block to avoid some code hitting
571558 // nil panics on access.
572- if mode == ethconfig . SnapSync && pivot == nil {
559+ if mode == SnapSync && pivot == nil {
573560 pivot = d .blockchain .CurrentBlock ()
574561 }
575562
@@ -599,7 +586,7 @@ func (d *Downloader) syncWithPeer(p *peerConnection, hash common.Hash, td, ttd *
599586 d .syncStatsLock .Unlock ()
600587
601588 // Ensure our origin point is below any snap sync pivot point
602- if mode == ethconfig . SnapSync {
589+ if mode == SnapSync {
603590 if height <= uint64 (fsMinFullBlocks ) {
604591 origin = 0
605592 } else {
@@ -614,10 +601,10 @@ func (d *Downloader) syncWithPeer(p *peerConnection, hash common.Hash, td, ttd *
614601 }
615602
616603 d .committed .Store (true )
617- if mode == ethconfig . SnapSync && pivot .Number .Uint64 () != 0 {
604+ if mode == SnapSync && pivot .Number .Uint64 () != 0 {
618605 d .committed .Store (false )
619606 }
620- if mode == ethconfig . SnapSync {
607+ if mode == SnapSync {
621608 // Set the ancient data limitation. If we are running snap sync, all block
622609 // data older than ancientLimit will be written to the ancient store. More
623610 // recent data will be written to the active database and will wait for the
@@ -694,13 +681,13 @@ func (d *Downloader) syncWithPeer(p *peerConnection, hash common.Hash, td, ttd *
694681 func () error { return d .processHeaders (origin + 1 , td , ttd , beaconMode ) },
695682 }
696683
697- if mode == ethconfig . SnapSync {
684+ if mode == SnapSync {
698685 d .pivotLock .Lock ()
699686 d .pivotHeader = pivot
700687 d .pivotLock .Unlock ()
701688
702689 fetchers = append (fetchers , func () error { return d .processSnapSyncContent () })
703- } else if mode == ethconfig . FullSync {
690+ } else if mode == FullSync {
704691 fetchers = append (fetchers , func () error { return d .processFullSyncContent (ttd , beaconMode ) })
705692 }
706693
@@ -1453,7 +1440,7 @@ func (d *Downloader) processHeaders(origin uint64, td, ttd *big.Int, beaconMode
14531440 chunkHashes := hashes [:limit ]
14541441
14551442 // In case of header only syncing, validate the chunk immediately
1456- if mode == ethconfig . SnapSync {
1443+ if mode == SnapSync {
14571444 // Although the received headers might be all valid, a legacy
14581445 // PoW/PoA sync must not accept post-merge headers. Make sure
14591446 // that any transition is rejected at this point.
0 commit comments