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 84db5d4 commit 773c425
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 27 deletions.
28 changes: 14 additions & 14 deletions triedb/pathdb/journal.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,24 +518,24 @@ 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)
}
nodeCopy := make([]nblJournalData, 0, len(nodes))
for i, val := range nodes {
nodeCopy[i] = val
log.Info("print nodeCopy111 multi layers node info", "index", i, "root", val.root, "layers", val.layers,
"size", val.size)
a := nodes[i]
log.Info("cfnwen", "a", a.size)
}
// nodeCopy := make([]nblJournalData, 0, len(nodes))
// for i, val := range nodes {
// nodeCopy[i] = val
// log.Info("print nodeCopy111 multi layers node info", "index", i, "root", val.root, "layers", val.layers,
// "size", val.size)
// a := nodes[i]
// log.Info("cfnwen", "a", a.size)
// }
// var nodeCopy []nblJournalData
// copy(nodeCopy, nodes)
log.Info("jnwvrjnrn")
for i, val := range nodeCopy {
log.Info("print nodeCopy multi layers node info", "index", i, "root", val.root, "layers", val.layers,
"size", val.size)
}
// log.Info("jnwvrjnrn")
// 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 {
if err := rlp.Encode(journalBuf, nodes); err != nil {
return err
}
log.Info("Journal file and node buffer list", "multi layer nodes count", len(nodes))
Expand Down
27 changes: 14 additions & 13 deletions triedb/pathdb/nodebufferlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,8 @@ func (nf *nodebufferlist) getMultiLayerNodes() []nblJournalData {
defer nf.mux.Unlock()
defer nf.baseMux.Unlock()

nodesArray := make([]nblJournalData, 0, nf.count+1)
var nodesArray []nblJournalData
// nodesArray := make([]nblJournalData, 0, nf.count+1)
nodesArray = append(nodesArray, nblJournalData{
root: nf.base.root,
layers: nf.base.layers,
Expand All @@ -582,18 +583,18 @@ func (nf *nodebufferlist) getMultiLayerNodes() []nblJournalData {
log.Info("getMultiLayerNodes base", "state_id", nf.base.id, "root", nf.base.root, "layers", nf.base.layers,
"size", nf.base.size)

// merge := func(buffer *multiDifflayer) bool {
// log.Info("getMultiLayerNodes", "state_id", buffer.id, "root", buffer.root, "layers", buffer.layers,
// "size", buffer.size)
// nodesArray = append(nodesArray, nblJournalData{
// root: buffer.root,
// layers: buffer.layers,
// size: buffer.size,
// nodes: compressTrieNodes(buffer.nodes),
// })
// return true
// }
// nf.traverseReverse(merge)
merge := func(buffer *multiDifflayer) bool {
log.Info("getMultiLayerNodes", "state_id", buffer.id, "root", buffer.root, "layers", buffer.layers,
"size", buffer.size)
nodesArray = append(nodesArray, nblJournalData{
root: buffer.root,
layers: buffer.layers,
size: buffer.size,
nodes: compressTrieNodes(buffer.nodes),
})
return true
}
nf.traverseReverse(merge)

for i, val := range nodesArray {
log.Info("print multi layers node info", "index", i, "root", val.root, "layers", val.layers,
Expand Down

0 comments on commit 773c425

Please sign in to comment.