From 0352fb5410b46c258d213079929d2cf7fd9526a0 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Tue, 28 Nov 2023 09:14:54 +0100 Subject: [PATCH] add state witness --- core/state/state_witness.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 core/state/state_witness.go diff --git a/core/state/state_witness.go b/core/state/state_witness.go new file mode 100644 index 0000000000..e6acbc83ad --- /dev/null +++ b/core/state/state_witness.go @@ -0,0 +1,35 @@ +package state + +import ( + "fmt" + + "github.com/ethereum/go-ethereum/common" +) + +type witness struct { + root common.Hash + lists []map[string][]byte + owners []common.Hash +} + +func newWitness(originalRoot common.Hash) *witness { + return &witness{root: originalRoot} +} + +func (w *witness) addAccessList(owner common.Hash, list map[string][]byte) { + if len(list) > 0 { + w.lists = append(w.lists, list) + w.owners = append(w.owners, owner) + } +} + +func (w *witness) Dump() { + fmt.Printf("Root %x\n", w.root) + for i, list := range w.lists { + owner := w.owners[i] + fmt.Printf("Owner %#x, %d entries: \n", owner, len(list)) + for path, v := range list { + fmt.Printf("- '%#x': %#x\n", path, v) + } + } +}