Skip to content

Commit e2952d4

Browse files
committed
trie: bloom-filter based pruning mechanism (ethereum#21724)
1 parent bfaf3c5 commit e2952d4

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

trie/stacktrie.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var stPool = sync.Pool{
3535
},
3636
}
3737

38-
func stackTrieFromPool(db ethdb.KeyValueStore) *StackTrie {
38+
func stackTrieFromPool(db ethdb.KeyValueWriter) *StackTrie {
3939
st := stPool.Get().(*StackTrie)
4040
st.db = db
4141
return st
@@ -50,24 +50,23 @@ func returnToPool(st *StackTrie) {
5050
// in order. Once it determines that a subtree will no longer be inserted
5151
// into, it will hash it and free up the memory it uses.
5252
type StackTrie struct {
53-
nodeType uint8 // node type (as in branch, ext, leaf)
54-
val []byte // value contained by this node if it's a leaf
55-
key []byte // key chunk covered by this (full|ext) node
56-
keyOffset int // offset of the key chunk inside a full key
57-
children [16]*StackTrie // list of children (for fullnodes and exts)
58-
59-
db ethdb.KeyValueStore // Pointer to the commit db, can be nil
53+
nodeType uint8 // node type (as in branch, ext, leaf)
54+
val []byte // value contained by this node if it's a leaf
55+
key []byte // key chunk covered by this (full|ext) node
56+
keyOffset int // offset of the key chunk inside a full key
57+
children [16]*StackTrie // list of children (for fullnodes and exts)
58+
db ethdb.KeyValueWriter // Pointer to the commit db, can be nil
6059
}
6160

6261
// NewStackTrie allocates and initializes an empty trie.
63-
func NewStackTrie(db ethdb.KeyValueStore) *StackTrie {
62+
func NewStackTrie(db ethdb.KeyValueWriter) *StackTrie {
6463
return &StackTrie{
6564
nodeType: emptyNode,
6665
db: db,
6766
}
6867
}
6968

70-
func newLeaf(ko int, key, val []byte, db ethdb.KeyValueStore) *StackTrie {
69+
func newLeaf(ko int, key, val []byte, db ethdb.KeyValueWriter) *StackTrie {
7170
st := stackTrieFromPool(db)
7271
st.nodeType = leafNode
7372
st.keyOffset = ko
@@ -76,7 +75,7 @@ func newLeaf(ko int, key, val []byte, db ethdb.KeyValueStore) *StackTrie {
7675
return st
7776
}
7877

79-
func newExt(ko int, key []byte, child *StackTrie, db ethdb.KeyValueStore) *StackTrie {
78+
func newExt(ko int, key []byte, child *StackTrie, db ethdb.KeyValueWriter) *StackTrie {
8079
st := stackTrieFromPool(db)
8180
st.nodeType = extNode
8281
st.keyOffset = ko

0 commit comments

Comments
 (0)