From 214d0674a0908ec9e66d37f42497c5274e7a10c9 Mon Sep 17 00:00:00 2001 From: VM Date: Sat, 23 Nov 2024 18:14:39 +0800 Subject: [PATCH] feat: journal nodebufferlist snapshot data for journal file recoering --- triedb/pathdb/journal.go | 1 + triedb/pathdb/nodebufferlist.go | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/triedb/pathdb/journal.go b/triedb/pathdb/journal.go index 82024b2b5..027c36bdb 100644 --- a/triedb/pathdb/journal.go +++ b/triedb/pathdb/journal.go @@ -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) } diff --git a/triedb/pathdb/nodebufferlist.go b/triedb/pathdb/nodebufferlist.go index 5a2e2b56e..77302914c 100644 --- a/triedb/pathdb/nodebufferlist.go +++ b/triedb/pathdb/nodebufferlist.go @@ -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 @@ -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,