Skip to content

Commit

Permalink
feat: journal nodebufferlist snapshot data for journal file recovering
Browse files Browse the repository at this point in the history
  • Loading branch information
VM committed Nov 25, 2024
1 parent 2237877 commit 959a23b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
5 changes: 3 additions & 2 deletions triedb/pathdb/journal.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,8 @@ func (dl *diskLayer) journal(w io.Writer, journalType JournalType) error {
return err
}
// Step three, write all unwritten nodes into the journal
nodes := compressTrieNodes(dl.buffer.getAllNodes())
bufferNodes := dl.buffer.getAllNodes()
nodes := compressTrieNodes(bufferNodes)
if err := rlp.Encode(journalBuf, nodes); err != nil {
return err
}
Expand All @@ -505,7 +506,7 @@ func (dl *diskLayer) journal(w io.Writer, journalType JournalType) error {
}
}

log.Info("Journaled pathdb disk layer", "root", dl.root)
log.Info("Journaled pathdb disk layer", "root", dl.root, "nodes", len(bufferNodes))
return nil
}

Expand Down
8 changes: 2 additions & 6 deletions triedb/pathdb/nodebufferlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,8 @@ func newNodeBufferList(
dlInMd = wpBlocks
}

if nodes == nil {
nodes = make(map[common.Hash]map[string]*trienode.Node)
}

var base *multiDifflayer
if nodes != nil {
if nodes != nil && !fastRecovery {
var size uint64
for _, subset := range nodes {
for path, n := range subset {
Expand Down Expand Up @@ -229,7 +225,7 @@ func (nf *nodebufferlist) recoverNodeBufferList(freezer *rawdb.ResettableFreezer
}
nf.diffToBase()

log.Info("Succeed to add diff layer", "base_size", nf.base.size, "tail_state_id", nf.tail.id,
log.Info("Succeed to recover node buffer list", "base_size", nf.base.size, "tail_state_id", nf.tail.id,
"head_state_id", nf.head.id, "nbl_layers", nf.layers, "base_layers", nf.base.layers)
return nil
}
Expand Down

0 comments on commit 959a23b

Please sign in to comment.