mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 04:36:42 +00:00
eth/downloader: rename GetSyncMode to ConfigSyncMode
This commit is contained in:
parent
e9a885a508
commit
9eaef994ce
5 changed files with 10 additions and 9 deletions
|
|
@ -747,7 +747,7 @@ func (api *ConsensusAPI) newPayload(params engine.ExecutableData, versionedHashe
|
|||
// tries to make it import a block. That should be denied as pushing something
|
||||
// into the database directly will conflict with the assumptions of snap sync
|
||||
// that it has an empty db that it can fill itself.
|
||||
if api.eth.Downloader().GetSyncMode() == ethconfig.SnapSync {
|
||||
if api.eth.Downloader().ConfigSyncMode() == ethconfig.SnapSync {
|
||||
return api.delayPayloadImport(block), nil
|
||||
}
|
||||
if !api.eth.BlockChain().HasBlockAndState(block.ParentHash(), block.NumberU64()-1) {
|
||||
|
|
@ -804,7 +804,7 @@ func (api *ConsensusAPI) delayPayloadImport(block *types.Block) engine.PayloadSt
|
|||
// payload as non-integratable on top of the existing sync. We'll just
|
||||
// have to rely on the beacon client to forcefully update the head with
|
||||
// a forkchoice update request.
|
||||
if api.eth.Downloader().GetSyncMode() == ethconfig.FullSync {
|
||||
if api.eth.Downloader().ConfigSyncMode() == ethconfig.FullSync {
|
||||
// In full sync mode, failure to import a well-formed block can only mean
|
||||
// that the parent state is missing and the syncer rejected extending the
|
||||
// current cycle with the new payload.
|
||||
|
|
|
|||
|
|
@ -424,8 +424,9 @@ func (d *Downloader) getMode() SyncMode {
|
|||
return SyncMode(d.mode.Load())
|
||||
}
|
||||
|
||||
// GetSyncMode returns the suggested sync mode.
|
||||
func (d *Downloader) GetSyncMode() SyncMode {
|
||||
// ConfigSyncMode returns the sync mode configured for the node.
|
||||
// The actual running sync mode can differ from this.
|
||||
func (d *Downloader) ConfigSyncMode() SyncMode {
|
||||
return d.moder.getMode()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ func newHandler(config *handlerConfig) (*handler, error) {
|
|||
h.downloader = downloader.New(config.Database, config.Sync, h.eventMux, h.chain, h.removePeer, h.enableSyncedFeatures)
|
||||
|
||||
// If snap sync is requested but snapshots are disabled, fail loudly
|
||||
if h.downloader.GetSyncMode() == ethconfig.SnapSync && (config.Chain.Snapshots() == nil && config.Chain.TrieDB().Scheme() == rawdb.HashScheme) {
|
||||
if h.downloader.ConfigSyncMode() == ethconfig.SnapSync && (config.Chain.Snapshots() == nil && config.Chain.TrieDB().Scheme() == rawdb.HashScheme) {
|
||||
return nil, errors.New("snap sync not supported with snapshots disabled")
|
||||
}
|
||||
fetchTx := func(peer string, hashes []common.Hash) error {
|
||||
|
|
@ -238,7 +238,7 @@ func (h *handler) runEthPeer(peer *eth.Peer, handler eth.Handler) error {
|
|||
return err
|
||||
}
|
||||
reject := false // reserved peer slots
|
||||
if h.downloader.GetSyncMode() == ethconfig.SnapSync {
|
||||
if h.downloader.ConfigSyncMode() == ethconfig.SnapSync {
|
||||
if snap == nil {
|
||||
// If we are running snap-sync, we want to reserve roughly half the peer
|
||||
// slots for peers supporting the snap protocol.
|
||||
|
|
@ -553,7 +553,7 @@ func (h *handler) blockRangeLoop(st *blockRangeState) {
|
|||
if ev == nil {
|
||||
continue
|
||||
}
|
||||
if _, ok := ev.Data.(downloader.StartEvent); ok && h.downloader.GetSyncMode() == ethconfig.SnapSync {
|
||||
if _, ok := ev.Data.(downloader.StartEvent); ok && h.downloader.ConfigSyncMode() == ethconfig.SnapSync {
|
||||
h.blockRangeWhileSnapSyncing(st)
|
||||
}
|
||||
case <-st.headCh:
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ func testSnapSyncDisabling(t *testing.T, ethVer uint, snapVer uint) {
|
|||
case <-timeout:
|
||||
t.Fatalf("snap sync not disabled after successful synchronisation")
|
||||
case <-time.After(100 * time.Millisecond):
|
||||
if empty.handler.downloader.GetSyncMode() == ethconfig.FullSync {
|
||||
if empty.handler.downloader.ConfigSyncMode() == ethconfig.FullSync {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ func (s *Syncer) run() {
|
|||
break
|
||||
}
|
||||
if resync {
|
||||
if mode := s.backend.Downloader().GetSyncMode(); mode != ethconfig.FullSync {
|
||||
if mode := s.backend.Downloader().ConfigSyncMode(); mode != ethconfig.FullSync {
|
||||
req.errc <- fmt.Errorf("unsupported syncmode %v, please relaunch geth with --syncmode full", mode)
|
||||
} else {
|
||||
req.errc <- s.backend.Downloader().BeaconDevSync(target)
|
||||
|
|
|
|||
Loading…
Reference in a new issue