aboutsummaryrefslogtreecommitdiffstats
path: root/core/headerchain.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2018-09-20 16:41:59 +0800
committerPéter Szilágyi <peterke@gmail.com>2018-09-20 17:56:35 +0800
commit0f2ba07c4122fbc2d836a2f374e5da8d8546e99f (patch)
treee86d2effb259d13ba43e476c81cc786d3f1b71dd /core/headerchain.go
parentc37238cae9b83aff0fc2413b3bb37f847c7949d6 (diff)
downloaddexon-0f2ba07c4122fbc2d836a2f374e5da8d8546e99f.tar
dexon-0f2ba07c4122fbc2d836a2f374e5da8d8546e99f.tar.gz
dexon-0f2ba07c4122fbc2d836a2f374e5da8d8546e99f.tar.bz2
dexon-0f2ba07c4122fbc2d836a2f374e5da8d8546e99f.tar.lz
dexon-0f2ba07c4122fbc2d836a2f374e5da8d8546e99f.tar.xz
dexon-0f2ba07c4122fbc2d836a2f374e5da8d8546e99f.tar.zst
dexon-0f2ba07c4122fbc2d836a2f374e5da8d8546e99f.zip
common, core, light: add block age into info logs
Diffstat (limited to 'core/headerchain.go')
-rw-r--r--core/headerchain.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/core/headerchain.go b/core/headerchain.go
index 2bbec28bf..d2093113c 100644
--- a/core/headerchain.go
+++ b/core/headerchain.go
@@ -281,8 +281,18 @@ func (hc *HeaderChain) InsertHeaderChain(chain []*types.Header, writeHeader WhCa
}
// Report some public statistics so the user has a clue what's going on
last := chain[len(chain)-1]
- log.Info("Imported new block headers", "count", stats.processed, "elapsed", common.PrettyDuration(time.Since(start)),
- "number", last.Number, "hash", last.Hash(), "ignored", stats.ignored)
+
+ context := []interface{}{
+ "count", stats.processed, "elapsed", common.PrettyDuration(time.Since(start)),
+ "number", last.Number, "hash", last.Hash(),
+ }
+ if timestamp := time.Unix(last.Time.Int64(), 0); time.Since(timestamp) > time.Minute {
+ context = append(context, []interface{}{"age", common.PrettyAge(timestamp)}...)
+ }
+ if stats.ignored > 0 {
+ context = append(context, []interface{}{"ignored", stats.ignored}...)
+ }
+ log.Info("Imported new block headers", context...)
return 0, nil
}