eth/downloader: rename moder

This commit is contained in:
Felix Lange 2025-12-08 20:02:40 +01:00
parent 9eaef994ce
commit 416006d035
2 changed files with 10 additions and 10 deletions

View file

@ -98,7 +98,7 @@ type headerTask struct {
type Downloader struct {
mode atomic.Uint32 // Synchronisation mode defining the strategy used (per sync cycle), use d.getMode() to get the SyncMode
moder *moder // Sync mode management, deliver the appropriate sync mode choice for each cycle
moder *syncModer // Sync mode management, deliver the appropriate sync mode choice for each cycle
mux *event.TypeMux // Event multiplexer to announce sync operation events
queue *queue // Scheduler for selecting the hashes to download
@ -361,7 +361,7 @@ func (d *Downloader) synchronise(beaconPing chan struct{}) (err error) {
if d.notified.CompareAndSwap(false, true) {
log.Info("Block synchronisation started")
}
mode := d.moder.getMode()
mode := d.moder.get()
defer func() {
if err == nil && mode == ethconfig.SnapSync {
d.moder.disableSnap()
@ -427,7 +427,7 @@ func (d *Downloader) getMode() 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()
return d.moder.get()
}
// syncToHead starts a block synchronization based on the hash chain from

View file

@ -25,17 +25,17 @@ import (
"github.com/ethereum/go-ethereum/log"
)
// moder is responsible for managing the downloader's sync mode. It takes the
// syncModer is responsible for managing the downloader's sync mode. It takes the
// user's preference at startup and then determines the appropriate sync mode
// based on the current chain status.
type moder struct {
type syncModer struct {
mode ethconfig.SyncMode
chain BlockChain
disk ethdb.KeyValueReader
lock sync.Mutex
}
func newSyncModer(mode ethconfig.SyncMode, chain BlockChain, disk ethdb.KeyValueReader) *moder {
func newSyncModer(mode ethconfig.SyncMode, chain BlockChain, disk ethdb.KeyValueReader) *syncModer {
if mode == ethconfig.FullSync {
// The database seems empty as the current block is the genesis. Yet the snap
// block is ahead, so snap sync was enabled for this node at a certain point.
@ -66,16 +66,16 @@ func newSyncModer(mode ethconfig.SyncMode, chain BlockChain, disk ethdb.KeyValue
log.Info("Enabled snap-sync", "head", head.Number, "hash", head.Hash())
}
}
return &moder{
return &syncModer{
mode: mode,
chain: chain,
disk: disk,
}
}
// getMode retrieves the current sync mode, either explicitly set, or derived
// get retrieves the current sync mode, either explicitly set, or derived
// from the chain status.
func (m *moder) getMode() ethconfig.SyncMode {
func (m *syncModer) get() ethconfig.SyncMode {
m.lock.Lock()
defer m.lock.Unlock()
@ -104,7 +104,7 @@ func (m *moder) getMode() ethconfig.SyncMode {
}
// disableSnap disables the snap sync mode, usually it's called after a successful snap sync.
func (m *moder) disableSnap() {
func (m *syncModer) disableSnap() {
m.lock.Lock()
m.mode = ethconfig.FullSync
m.lock.Unlock()