From 33d6f5d03bc11c5f7e0b7af41cbb09858c2da8ca Mon Sep 17 00:00:00 2001 From: "will@2012" Date: Wed, 13 Mar 2024 20:16:23 +0800 Subject: [PATCH] chore: polish log format by review tips --- trie/triedb/pathdb/asyncnodebuffer.go | 14 +++++++------- trie/triedb/pathdb/disklayer.go | 4 ++-- trie/triedb/pathdb/layertree.go | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/trie/triedb/pathdb/asyncnodebuffer.go b/trie/triedb/pathdb/asyncnodebuffer.go index 2c96fedc02..a94fab4461 100644 --- a/trie/triedb/pathdb/asyncnodebuffer.go +++ b/trie/triedb/pathdb/asyncnodebuffer.go @@ -72,7 +72,7 @@ func (a *asyncnodebuffer) commit(nodes map[common.Hash]map[string]*trienode.Node err := a.current.commit(nodes) if err != nil { - log.Crit("[BUG] failed to commit nodes to asyncnodebuffer", "error", err) + log.Crit("[BUG] Failed to commit nodes to asyncnodebuffer", "error", err) } return a } @@ -87,7 +87,7 @@ func (a *asyncnodebuffer) revert(db ethdb.KeyValueReader, nodes map[common.Hash] var err error a.current, err = a.current.merge(a.background) if err != nil { - log.Crit("[BUG] failed to merge node cache under revert async node buffer", "error", err) + log.Crit("[BUG] Failed to merge node cache under revert async node buffer", "error", err) } a.background.reset() return a.current.revert(db, nodes) @@ -129,7 +129,7 @@ func (a *asyncnodebuffer) flush(db ethdb.KeyValueStore, clean *fastcache.Cache, for { if atomic.LoadUint64(&a.background.immutable) == 1 { time.Sleep(time.Duration(DefaultBackgroundFlushInterval) * time.Second) - log.Info("waiting background memory table flushed into disk for forcing flush node buffer") + log.Info("Waiting background memory table flushed into disk for forcing flush node buffer") continue } atomic.StoreUint64(&a.current.immutable, 1) @@ -155,10 +155,10 @@ func (a *asyncnodebuffer) flush(db ethdb.KeyValueStore, clean *fastcache.Cache, for { err := a.background.flush(db, clean, persistID) if err == nil { - log.Debug("succeed to flush background nodecache to disk", "state_id", persistID) + log.Debug("Succeed to flush background nodecache to disk", "state_id", persistID) return } - log.Error("failed to flush background nodecache to disk", "state_id", persistID, "error", err) + log.Error("Failed to flush background nodecache to disk", "state_id", persistID, "error", err) } }(id) return nil @@ -168,7 +168,7 @@ func (a *asyncnodebuffer) waitAndStopFlushing() { a.stopFlushing.Store(true) for a.isFlushing.Load() { time.Sleep(time.Second) - log.Warn("waiting background memory table flushed into disk") + log.Warn("Waiting background memory table flushed into disk") } } @@ -178,7 +178,7 @@ func (a *asyncnodebuffer) getAllNodes() map[common.Hash]map[string]*trienode.Nod cached, err := a.current.merge(a.background) if err != nil { - log.Crit("[BUG] failed to merge node cache under revert async node buffer", "error", err) + log.Crit("[BUG] Failed to merge node cache under revert async node buffer", "error", err) } return cached.nodes } diff --git a/trie/triedb/pathdb/disklayer.go b/trie/triedb/pathdb/disklayer.go index 6537696458..82023c669a 100644 --- a/trie/triedb/pathdb/disklayer.go +++ b/trie/triedb/pathdb/disklayer.go @@ -79,10 +79,10 @@ type trienodebuffer interface { func NewTrieNodeBuffer(sync bool, limit int, nodes map[common.Hash]map[string]*trienode.Node, layers uint64) trienodebuffer { if sync { - log.Info("new sync node buffer", "limit", common.StorageSize(limit), "layers", layers) + log.Info("New sync node buffer", "limit", common.StorageSize(limit), "layers", layers) return newNodeBuffer(limit, nodes, layers) } - log.Info("new async node buffer", "limit", common.StorageSize(limit), "layers", layers) + log.Info("New async node buffer", "limit", common.StorageSize(limit), "layers", layers) return newAsyncNodeBuffer(limit, nodes, layers) } diff --git a/trie/triedb/pathdb/layertree.go b/trie/triedb/pathdb/layertree.go index ed94d2e19e..7c59bffb4d 100644 --- a/trie/triedb/pathdb/layertree.go +++ b/trie/triedb/pathdb/layertree.go @@ -239,18 +239,18 @@ func (tree *layerTree) front() common.Hash { } } if (base == common.Hash{}) { - log.Info("pathdb top difflayer is empty") + log.Info("Pathdb top difflayer is empty") return base } parent := base for { children, ok := chain[parent] if !ok { - log.Info("pathdb top difflayer", "root", parent) + log.Info("Pathdb top difflayer", "root", parent) return parent } if len(children) != 1 { - log.Info("pathdb top difflayer is forked", "common ancestor root", parent) + log.Info("Pathdb top difflayer is forked", "common ancestor root", parent) return parent } parent = children[0]