Skip to content

Commit

Permalink
feat: journal nodebufferlist snapshot data for journal file recoering
Browse files Browse the repository at this point in the history
  • Loading branch information
VM committed Nov 23, 2024
1 parent 0a89adc commit 214d067
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions triedb/pathdb/journal.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ func (db *Database) loadDiskLayer(r *rlp.Stream, journalTypeForReader JournalTyp
var nodesArray []nblJournalData

if db.config.TrieNodeBufferType == NodeBufferList && journalTypeForReader == JournalFileType && !db.fastRecovery {
log.Info("decode journal file data")
if err := journalBuf.Decode(&nodesArray); err != nil {
return nil, fmt.Errorf("11 failed to load disk nodes: %v", err)
}
Expand Down
7 changes: 6 additions & 1 deletion triedb/pathdb/nodebufferlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ func newNodeBufferList(

var base *multiDifflayer
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)
} else if nodes != nil {
var size uint64
Expand Down Expand Up @@ -577,9 +579,12 @@ func (nf *nodebufferlist) getMultiLayerNodes() []nblJournalData {
size: nf.base.size,
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)

merge := func(buffer *multiDifflayer) bool {
log.Info("getMultiLayerNodes", "root", buffer.root, "layers", buffer.layers, "size", buffer.size)
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,
Expand Down

0 comments on commit 214d067

Please sign in to comment.