mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 20:26:41 +00:00
eth/downloader: add more logs
This commit is contained in:
parent
af8e152501
commit
1a5f94b5d9
4 changed files with 12 additions and 5 deletions
|
|
@ -114,7 +114,9 @@ func (b *beaconBackfiller) resume() {
|
|||
if b.success != nil {
|
||||
b.success()
|
||||
}
|
||||
log.Debug("Backfilling completed")
|
||||
}()
|
||||
log.Debug("Backfilling started")
|
||||
}
|
||||
|
||||
// SetBadBlockCallback sets the callback to run when a bad block is hit by the
|
||||
|
|
|
|||
|
|
@ -367,7 +367,7 @@ func (d *Downloader) synchronise(beaconPing chan struct{}) (err error) {
|
|||
}
|
||||
|
||||
// Obtain the synchronized used in this cycle
|
||||
mode := d.moder.get()
|
||||
mode := d.moder.get(true)
|
||||
defer func() {
|
||||
if err == nil && mode == ethconfig.SnapSync {
|
||||
d.moder.disableSnap()
|
||||
|
|
@ -424,7 +424,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.get()
|
||||
return d.moder.get(false)
|
||||
}
|
||||
|
||||
// syncToHead starts a block synchronization based on the hash chain from
|
||||
|
|
|
|||
|
|
@ -510,6 +510,7 @@ func (s *skeleton) sync(head *types.Header) (*types.Header, error) {
|
|||
// The skeleton chain is no longer linked to the local chain for some reason
|
||||
// (e.g. debug_setHead was used to trim the local chain). Re-schedule the
|
||||
// skeleton sync to fill the chain gap.
|
||||
log.Warn("Local chain has been trimmed", "tailnumber", s.scratchHead, "tailhash", s.progress.Subchains[0].Next)
|
||||
return nil, errSyncTrimmed
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ func newSyncModer(mode ethconfig.SyncMode, chain BlockChain, disk ethdb.KeyValue
|
|||
|
||||
// get retrieves the current sync mode, either explicitly set, or derived
|
||||
// from the chain status.
|
||||
func (m *syncModer) get() ethconfig.SyncMode {
|
||||
func (m *syncModer) get(report bool) ethconfig.SyncMode {
|
||||
m.lock.Lock()
|
||||
defer m.lock.Unlock()
|
||||
|
||||
|
|
@ -83,12 +83,16 @@ func (m *syncModer) get() ethconfig.SyncMode {
|
|||
if m.mode == ethconfig.SnapSync {
|
||||
return ethconfig.SnapSync
|
||||
}
|
||||
logger := log.Debug
|
||||
if report {
|
||||
logger = log.Info
|
||||
}
|
||||
// We are probably in full sync, but we might have rewound to before the
|
||||
// snap sync pivot, check if we should re-enable snap sync.
|
||||
head := m.chain.CurrentBlock()
|
||||
if pivot := rawdb.ReadLastPivotNumber(m.disk); pivot != nil {
|
||||
if head.Number.Uint64() < *pivot {
|
||||
log.Info("Reenabled snap-sync as chain is lagging behind the pivot", "head", head.Number, "pivot", pivot)
|
||||
logger("Reenabled snap-sync as chain is lagging behind the pivot", "head", head.Number, "pivot", pivot)
|
||||
return ethconfig.SnapSync
|
||||
}
|
||||
}
|
||||
|
|
@ -96,7 +100,7 @@ func (m *syncModer) get() ethconfig.SyncMode {
|
|||
// the head state, forcefully rerun the snap sync. Note it doesn't mean the
|
||||
// persistent state is corrupted, just mismatch with the head block.
|
||||
if !m.chain.HasState(head.Root) {
|
||||
log.Info("Reenabled snap-sync as chain is stateless")
|
||||
logger("Reenabled snap-sync as chain is stateless")
|
||||
return ethconfig.SnapSync
|
||||
}
|
||||
// Nope, we're really full syncing
|
||||
|
|
|
|||
Loading…
Reference in a new issue