Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eth/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ func (pm *ProtocolManager) Start(maxPeers int) {
// start sync handlers
go pm.syncer()
go pm.txsyncLoop()
go pm.syncStatusLogger()
}

func (pm *ProtocolManager) Stop() {
Expand Down
34 changes: 34 additions & 0 deletions eth/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ const (
// This is the target size for the packs of transactions sent by txsyncLoop.
// A pack can get larger than this if a single transactions exceeds this size.
txsyncPackSize = 100 * 1024

// syncStatusLogCycle is the interval at which the current sync status is
// reported at warn level, so it is visible even when info/debug logs are
// filtered out.
syncStatusLogCycle = 10 * time.Minute
)

type txsync struct {
Expand Down Expand Up @@ -167,6 +172,35 @@ func (pm *ProtocolManager) syncer() {
}
}

// syncStatusLogger periodically reports the current sync status at warn
// level so that it is always visible in the logs, regardless of whether
// info/debug logs are enabled, and independent of the one-shot start/finish
// logs emitted by the downloader itself.
func (pm *ProtocolManager) syncStatusLogger() {
ticker := time.NewTicker(syncStatusLogCycle)
defer ticker.Stop()

for {
select {
case <-ticker.C:
if pm.downloader.Synchronising() {
progress := pm.downloader.Progress()
log.Warn("Block synchronisation in progress",
"starting", progress.StartingBlock,
"current", progress.CurrentBlock,
Comment thread
benjamin202410 marked this conversation as resolved.
"highest", progress.HighestBlock,
"pulledStates", progress.PulledStates,
"knownStates", progress.KnownStates,
"peers", pm.peers.Len(),
)
}

case <-pm.quitSync:
return
}
}
}

// synchronise tries to sync up our local block chain with a remote peer.
func (pm *ProtocolManager) synchronise(peer *peer) {
// Short circuit if no peers are available
Expand Down
Loading