mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
trie: bloom-filter based pruning mechanism (#21724)
This commit is contained in:
parent
5b8c267122
commit
dcea73039c
1 changed files with 10 additions and 11 deletions
|
|
@ -35,7 +35,7 @@ var stPool = sync.Pool{
|
|||
},
|
||||
}
|
||||
|
||||
func stackTrieFromPool(db ethdb.KeyValueStore) *StackTrie {
|
||||
func stackTrieFromPool(db ethdb.KeyValueWriter) *StackTrie {
|
||||
st := stPool.Get().(*StackTrie)
|
||||
st.db = db
|
||||
return st
|
||||
|
|
@ -50,24 +50,23 @@ func returnToPool(st *StackTrie) {
|
|||
// in order. Once it determines that a subtree will no longer be inserted
|
||||
// into, it will hash it and free up the memory it uses.
|
||||
type StackTrie struct {
|
||||
nodeType uint8 // node type (as in branch, ext, leaf)
|
||||
val []byte // value contained by this node if it's a leaf
|
||||
key []byte // key chunk covered by this (full|ext) node
|
||||
keyOffset int // offset of the key chunk inside a full key
|
||||
children [16]*StackTrie // list of children (for fullnodes and exts)
|
||||
|
||||
db ethdb.KeyValueStore // Pointer to the commit db, can be nil
|
||||
nodeType uint8 // node type (as in branch, ext, leaf)
|
||||
val []byte // value contained by this node if it's a leaf
|
||||
key []byte // key chunk covered by this (full|ext) node
|
||||
keyOffset int // offset of the key chunk inside a full key
|
||||
children [16]*StackTrie // list of children (for fullnodes and exts)
|
||||
db ethdb.KeyValueWriter // Pointer to the commit db, can be nil
|
||||
}
|
||||
|
||||
// NewStackTrie allocates and initializes an empty trie.
|
||||
func NewStackTrie(db ethdb.KeyValueStore) *StackTrie {
|
||||
func NewStackTrie(db ethdb.KeyValueWriter) *StackTrie {
|
||||
return &StackTrie{
|
||||
nodeType: emptyNode,
|
||||
db: db,
|
||||
}
|
||||
}
|
||||
|
||||
func newLeaf(ko int, key, val []byte, db ethdb.KeyValueStore) *StackTrie {
|
||||
func newLeaf(ko int, key, val []byte, db ethdb.KeyValueWriter) *StackTrie {
|
||||
st := stackTrieFromPool(db)
|
||||
st.nodeType = leafNode
|
||||
st.keyOffset = ko
|
||||
|
|
@ -76,7 +75,7 @@ func newLeaf(ko int, key, val []byte, db ethdb.KeyValueStore) *StackTrie {
|
|||
return st
|
||||
}
|
||||
|
||||
func newExt(ko int, key []byte, child *StackTrie, db ethdb.KeyValueStore) *StackTrie {
|
||||
func newExt(ko int, key []byte, child *StackTrie, db ethdb.KeyValueWriter) *StackTrie {
|
||||
st := stackTrieFromPool(db)
|
||||
st.nodeType = extNode
|
||||
st.keyOffset = ko
|
||||
|
|
|
|||
Loading…
Reference in a new issue