mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 12:46:44 +00:00
eth/downloader: rename moder
This commit is contained in:
parent
9eaef994ce
commit
416006d035
2 changed files with 10 additions and 10 deletions
|
|
@ -98,7 +98,7 @@ type headerTask struct {
|
||||||
|
|
||||||
type Downloader struct {
|
type Downloader struct {
|
||||||
mode atomic.Uint32 // Synchronisation mode defining the strategy used (per sync cycle), use d.getMode() to get the SyncMode
|
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
|
mux *event.TypeMux // Event multiplexer to announce sync operation events
|
||||||
|
|
||||||
queue *queue // Scheduler for selecting the hashes to download
|
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) {
|
if d.notified.CompareAndSwap(false, true) {
|
||||||
log.Info("Block synchronisation started")
|
log.Info("Block synchronisation started")
|
||||||
}
|
}
|
||||||
mode := d.moder.getMode()
|
mode := d.moder.get()
|
||||||
defer func() {
|
defer func() {
|
||||||
if err == nil && mode == ethconfig.SnapSync {
|
if err == nil && mode == ethconfig.SnapSync {
|
||||||
d.moder.disableSnap()
|
d.moder.disableSnap()
|
||||||
|
|
@ -427,7 +427,7 @@ func (d *Downloader) getMode() SyncMode {
|
||||||
// ConfigSyncMode returns the sync mode configured for the node.
|
// ConfigSyncMode returns the sync mode configured for the node.
|
||||||
// The actual running sync mode can differ from this.
|
// The actual running sync mode can differ from this.
|
||||||
func (d *Downloader) ConfigSyncMode() SyncMode {
|
func (d *Downloader) ConfigSyncMode() SyncMode {
|
||||||
return d.moder.getMode()
|
return d.moder.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// syncToHead starts a block synchronization based on the hash chain from
|
// syncToHead starts a block synchronization based on the hash chain from
|
||||||
|
|
|
||||||
|
|
@ -25,17 +25,17 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"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
|
// user's preference at startup and then determines the appropriate sync mode
|
||||||
// based on the current chain status.
|
// based on the current chain status.
|
||||||
type moder struct {
|
type syncModer struct {
|
||||||
mode ethconfig.SyncMode
|
mode ethconfig.SyncMode
|
||||||
chain BlockChain
|
chain BlockChain
|
||||||
disk ethdb.KeyValueReader
|
disk ethdb.KeyValueReader
|
||||||
lock sync.Mutex
|
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 {
|
if mode == ethconfig.FullSync {
|
||||||
// The database seems empty as the current block is the genesis. Yet the snap
|
// 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.
|
// 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())
|
log.Info("Enabled snap-sync", "head", head.Number, "hash", head.Hash())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return &moder{
|
return &syncModer{
|
||||||
mode: mode,
|
mode: mode,
|
||||||
chain: chain,
|
chain: chain,
|
||||||
disk: disk,
|
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.
|
// from the chain status.
|
||||||
func (m *moder) getMode() ethconfig.SyncMode {
|
func (m *syncModer) get() ethconfig.SyncMode {
|
||||||
m.lock.Lock()
|
m.lock.Lock()
|
||||||
defer m.lock.Unlock()
|
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.
|
// 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.lock.Lock()
|
||||||
m.mode = ethconfig.FullSync
|
m.mode = ethconfig.FullSync
|
||||||
m.lock.Unlock()
|
m.lock.Unlock()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue