diff --git a/eth/handler.go b/eth/handler.go index 6ce236a7d9b2..b24636be7c32 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -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() { diff --git a/eth/sync.go b/eth/sync.go index f299d815a35d..d1644a03daee 100644 --- a/eth/sync.go +++ b/eth/sync.go @@ -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 { @@ -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, + "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