Skip to content

Commit

Permalink
chore: polish log format by review tips
Browse files Browse the repository at this point in the history
  • Loading branch information
will@2012 committed Mar 13, 2024
1 parent 1746064 commit 33d6f5d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions trie/triedb/pathdb/asyncnodebuffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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")
}
}

Expand All @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions trie/triedb/pathdb/disklayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
6 changes: 3 additions & 3 deletions trie/triedb/pathdb/layertree.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 33d6f5d

Please sign in to comment.