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 TransactionStorage
- func (t *TransactionStorage) Delete(key *Key) error
- func (t *TransactionStorage) DeleteRootKey() error
- func (t *TransactionStorage) Get(key *Key) (*Node, error)
- func (t *TransactionStorage) Put(key *Key, value *Node) error
- func (t *TransactionStorage) PutRootKey(newRootKey *Key) error
- func (t *TransactionStorage) RootKey() (*Key, error)
- func (t *TransactionStorage) SyncedStorage() *TransactionStorage
- 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 NewTrieFunc ¶ added in v0.2.1
type NewTrieFunc func(*TransactionStorage, uint8) (*Trie, error)
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 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 *Key) 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 *Key) (*Node, error)
func (*TransactionStorage) Put ¶ added in v0.3.0
func (t *TransactionStorage) Put(key *Key, value *Node) error
func (*TransactionStorage) PutRootKey ¶ added in v0.4.0
func (t *TransactionStorage) PutRootKey(newRootKey *Key) error
func (*TransactionStorage) RootKey ¶ added in v0.4.0
func (t *TransactionStorage) RootKey() (*Key, error)
func (*TransactionStorage) SyncedStorage ¶ added in v0.7.2
func (t *TransactionStorage) SyncedStorage() *TransactionStorage
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.
func NewTriePedersen ¶ added in v0.2.1
func NewTriePedersen(storage *TransactionStorage, height uint8) (*Trie, error)
func NewTriePoseidon ¶ added in v0.2.1
func NewTriePoseidon(storage *TransactionStorage, height uint8) (*Trie, error)