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 24, 2024
1 parent da032d3 commit 518a7ab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
7 changes: 3 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 @@ -346,11 +346,10 @@ func (db *Database) loadDiskLayer(r *rlp.Stream, journalTypeForReader JournalTyp

if db.config.TrieNodeBufferType == NodeBufferList && journalTypeForReader == JournalFileType && !db.fastRecovery {
log.Info("decode journal file data")
var nnn []nblJournalData
if err := journalBuf.Decode(&nnn); err != nil {
if err := journalBuf.Decode(&nodesArray); err != nil {
return nil, fmt.Errorf("11 failed to load disk nodes: %v", err)
}
for i, val := range nnn {
for i, val := range nodesArray {
log.Info("print load decode layers node info", "index", i, "root", val.root, "layers", val.layers,
"size", val.size)
}
Expand Down
8 changes: 4 additions & 4 deletions triedb/pathdb/nodebufferlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func newNodeBufferList(
if nodesArray != nil {
log.Info("new base for journal file", "root", nodesArray[0].root, "layers", nodesArray[0].layers,
"size", nodesArray[0].size)
base = newMultiDifflayer(limit, nodesArray[0].size, nodesArray[0].root, flattenTrieNodes(nodesArray[0].nodes), nodesArray[0].layers)
base = newMultiDifflayer(limit, nodesArray[0].size, nodesArray[0].root, nil, nodesArray[0].layers)
} else if nodes != nil {
var size uint64
for _, subset := range nodes {
Expand Down Expand Up @@ -558,7 +558,7 @@ func (nf *nodebufferlist) recoverJournalData(nodesArray []nblJournalData) {
length := len(nodesArray)
for i := 1; i < length; i++ {
log.Info("recoverJournalData", "size", nodesArray[i].size, "root", nodesArray[i].root, "layers", nodesArray[i].layers)
mdl := newMultiDifflayer(nf.limit, nodesArray[i].size, nodesArray[i].root, flattenTrieNodes(nodesArray[i].nodes), nodesArray[i].layers)
mdl := newMultiDifflayer(nf.limit, nodesArray[i].size, nodesArray[i].root, nil, nodesArray[i].layers)
nf.pushFront(mdl)
}
nf.count = uint64(length) - 1
Expand All @@ -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 518a7ab

Please sign in to comment.