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 d2b38bf commit aa7f6df
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
14 changes: 10 additions & 4 deletions triedb/pathdb/journal.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ type nblJournalData struct {
root common.Hash
layers uint64
size uint64
// nodes []journalNodes
nodes []journalNodes
}

// journalAccounts represents a list accounts belong to the layer.
Expand Down Expand Up @@ -518,9 +518,15 @@ func (dl *diskLayer) journal(w io.Writer, journalType JournalType) error {
log.Info("print journal multi layers node info", "index", i, "root", val.root, "layers", val.layers,
"size", val.size)
}
layerNum := dl.buffer.getLayers()
log.Info("print journal layers", "layer", layerNum)
if err := rlp.Encode(journalBuf, layerNum); err != nil {
var nodeCopy []nblJournalData
copy(nodeCopy, nodes)
for i, val := range nodeCopy {
log.Info("print nodeCopy multi layers node info", "index", i, "root", val.root, "layers", val.layers,
"size", val.size)
}
// layerNum := dl.buffer.getLayers()
// log.Info("print journal layers", "layer", layerNum)
if err := rlp.Encode(journalBuf, nodeCopy); err != nil {
return err
}
log.Info("Journal file and node buffer list", "multi layer nodes count", len(nodes))
Expand Down
4 changes: 2 additions & 2 deletions triedb/pathdb/nodebufferlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ func (nf *nodebufferlist) getMultiLayerNodes() []nblJournalData {
root: nf.base.root,
layers: nf.base.layers,
size: nf.base.size,
// nodes: compressTrieNodes(nf.base.nodes),
nodes: compressTrieNodes(nf.base.nodes),
})
log.Info("getMultiLayerNodes base", "state_id", nf.base.id, "root", nf.base.root, "layers", nf.base.layers,
"size", nf.base.size)
Expand All @@ -589,7 +589,7 @@ func (nf *nodebufferlist) getMultiLayerNodes() []nblJournalData {
root: buffer.root,
layers: buffer.layers,
size: buffer.size,
// nodes: compressTrieNodes(buffer.nodes),
nodes: compressTrieNodes(buffer.nodes),
})
return true
}
Expand Down

0 comments on commit aa7f6df

Please sign in to comment.