From d2b38bf32bd5010eec3965e7dccc32259cc86ee6 Mon Sep 17 00:00:00 2001 From: VM Date: Mon, 25 Nov 2024 10:29:12 +0800 Subject: [PATCH] feat: journal nodebufferlist snapshot data for journal file recovering --- triedb/pathdb/journal.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/triedb/pathdb/journal.go b/triedb/pathdb/journal.go index c060ac3b0..581014f7e 100644 --- a/triedb/pathdb/journal.go +++ b/triedb/pathdb/journal.go @@ -346,13 +346,15 @@ func (db *Database) loadDiskLayer(r *rlp.Stream, journalTypeForReader JournalTyp if db.config.TrieNodeBufferType == NodeBufferList && journalTypeForReader == JournalFileType && !db.fastRecovery { log.Info("decode journal file data") - if err := journalBuf.Decode(&nodesArray); err != nil { + var layerNum uint64 + if err := journalBuf.Decode(&layerNum); err != nil { return nil, fmt.Errorf("11 failed to load disk nodes: %v", err) } - for i, val := range nodesArray { - log.Info("print load decode layers node info", "index", i, "root", val.root, "layers", val.layers, - "size", val.size) - } + log.Info("print load layers", "layer", layerNum) + // for i, val := range nodesArray { + // log.Info("print load decode layers node info", "index", i, "root", val.root, "layers", val.layers, + // "size", val.size) + // } } else { // Resolve nodes cached in node buffer var encoded []journalNodes @@ -516,7 +518,9 @@ 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) } - if err := rlp.Encode(journalBuf, nodes); err != nil { + layerNum := dl.buffer.getLayers() + log.Info("print journal layers", "layer", layerNum) + if err := rlp.Encode(journalBuf, layerNum); err != nil { return err } log.Info("Journal file and node buffer list", "multi layer nodes count", len(nodes))