Documentation ¶
Overview ¶
Package trie implements a dense Merkle Patricia Trie. See the documentation on Trie for details.
Index ¶
- func RunOnTempTrie(height uint8, do func(*Trie) error) error
- type Key
- func (k *Key) DeleteLSB(n uint8)
- func (k *Key) EncodedLen() uint
- func (k *Key) Equal(other *Key) bool
- func (k *Key) Felt() felt.Felt
- func (k *Key) Len() uint8
- func (k *Key) String() string
- func (k *Key) Test(bit uint8) bool
- func (k *Key) Truncate(length uint8)
- func (k *Key) UnmarshalBinary(data []byte) error
- func (k *Key) WriteTo(buf *bytes.Buffer) (int64, error)
- type NewTrieFunc
- type Node
- type Storage
- func (t *Storage) Delete(key *Key) error
- func (t *Storage) DeleteRootKey() error
- func (t *Storage) Get(key *Key) (*Node, error)
- func (t *Storage) Put(key *Key, value *Node) error
- func (t *Storage) PutRootKey(newRootKey *Key) error
- func (t *Storage) RootKey() (*Key, error)
- func (t *Storage) SyncedStorage() *Storage
- type Trie
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Key ¶ added in v0.6.0
type Key struct {
// contains filtered or unexported fields
}
func (*Key) EncodedLen ¶ added in v0.6.0
func (*Key) Truncate ¶ added in v0.6.0
Truncate truncates key to `length` bits by clearing the remaining upper bits
func (*Key) UnmarshalBinary ¶ added in v0.6.0
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 struct {
// contains filtered or unexported fields
}
TransactionStorage is a database transaction on a trie.
func NewStorage ¶ added in v0.11.6
func NewStorage(txn db.Transaction, prefix []byte) *Storage
func (*Storage) DeleteRootKey ¶ added in v0.4.0
func (*Storage) PutRootKey ¶ added in v0.4.0
func (*Storage) SyncedStorage ¶ added in v0.11.6
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.