Documentation ¶
Overview ¶
Package trie implements a dense Merkle Patricia Trie. See the documentation on Trie for details.
Index ¶
- func RunOnTempTrie(height uint, do func(*Trie) error) error
- type NewTrieFunc
- type Node
- type Storage
- type TransactionStorage
- func (t *TransactionStorage) Delete(key *bitset.BitSet) error
- func (t *TransactionStorage) DeleteRootKey() error
- func (t *TransactionStorage) Get(key *bitset.BitSet) (*Node, error)
- func (t *TransactionStorage) Put(key *bitset.BitSet, value *Node) error
- func (t *TransactionStorage) PutRootKey(newRootKey *bitset.BitSet) error
- func (t *TransactionStorage) RootKey() (*bitset.BitSet, error)
- type Trie
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Node ¶
A Node represents a node in the Trie
func (*Node) UnmarshalBinary ¶ added in v0.4.0
UnmarshalBinary deserializes a Node from a byte array
type Storage ¶
type Storage interface { Put(key *bitset.BitSet, value *Node) error Get(key *bitset.BitSet) (*Node, error) Delete(key *bitset.BitSet) error PutRootKey(newRootKey *bitset.BitSet) error RootKey() (*bitset.BitSet, error) DeleteRootKey() error }
Storage is the Persistent storage for the Trie
type TransactionStorage ¶ added in v0.3.0
type TransactionStorage struct {
// contains filtered or unexported fields
}
TransactionStorage is a database transaction on a trie.
func NewTransactionStorage ¶ added in v0.3.0
func NewTransactionStorage(txn db.Transaction, prefix []byte) *TransactionStorage
func (*TransactionStorage) Delete ¶ added in v0.3.0
func (t *TransactionStorage) Delete(key *bitset.BitSet) error
func (*TransactionStorage) DeleteRootKey ¶ added in v0.4.0
func (t *TransactionStorage) DeleteRootKey() error
func (*TransactionStorage) Get ¶ added in v0.3.0
func (t *TransactionStorage) Get(key *bitset.BitSet) (*Node, error)
func (*TransactionStorage) Put ¶ added in v0.3.0
func (t *TransactionStorage) Put(key *bitset.BitSet, value *Node) error
func (*TransactionStorage) PutRootKey ¶ added in v0.4.0
func (t *TransactionStorage) PutRootKey(newRootKey *bitset.BitSet) error
type Trie ¶
type Trie struct {
// contains filtered or unexported fields
}
Trie is a dense Merkle Patricia Trie (i.e., all internal nodes have two children).
This implementation allows for a "flat" storage by keying nodes on their path rather than their hash, resulting in O(1) accesses and O(log n) insertions.
The state trie specification describes a sparse Merkle Trie. Note that this dense implementation results in an equivalent commitment.
Terminology:
- path: represents the path as defined in the specification. Together with len, represents a relative path from the current node to the node's nearest non-empty child.
- len: represents the len as defined in the specification. The number of bits to take from the fixed-length path to reach the nearest non-empty child.
- key: represents the storage key for trie [Node]s. It is the full path to the node from the root.