add state witness

This commit is contained in:
Martin Holst Swende 2023-11-28 09:14:54 +01:00
parent 387b0fe6e8
commit 0352fb5410
No known key found for this signature in database
GPG key ID: 683B438C05A5DDF0

View file

@ -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)
}
}
}