Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrInvalidTrie indicates something wrong causing invalid operation ErrInvalidTrie = errors.New("invalid trie operation") // ErrNotExist indicates entry does not exist ErrNotExist = errors.New("not exist in trie") // ErrEndOfIterator defines an error which will be returned ErrEndOfIterator = errors.New("hit the end of the iterator, no more item") )
Functions ¶
This section is empty.
Types ¶
type KVStore ¶
type KVStore interface { // Start starts the KVStore Start(context.Context) error // Stop stops the KVStore Stop(context.Context) error // Put puts key, value pair into KVStore Put([]byte, []byte) error // Delete deletes record from KVStore by key Delete([]byte) error // Get gets the value from KVStore by key Get([]byte) ([]byte, error) }
KVStore defines an interface for storing trie data as key-value pair
func NewKVStore ¶ added in v0.11.0
func NewKVStore(bucket string, dao db.KVStoreBasic) (KVStore, error)
NewKVStore creates a new KVStore
func NewMemKVStore ¶ added in v1.1.0
func NewMemKVStore() KVStore
NewMemKVStore defines a kv store in memory
type Trie ¶
type Trie interface { // Start starts the trie and the corresponding dependencies Start(context.Context) error // Stop stops the trie Stop(context.Context) error // Upsert inserts a new entry Upsert([]byte, []byte) error // Get retrieves an existing entry Get([]byte) ([]byte, error) // Delete deletes an entry Delete([]byte) error // RootHash returns trie's root hash RootHash() ([]byte, error) // SetRootHash sets a new root to trie SetRootHash([]byte) error // IsEmpty returns true is this is an empty trie IsEmpty() bool // Clone clones a trie with a new kvstore Clone(KVStore) (Trie, error) }
Trie is the interface of Merkle Patricia Trie
type TwoLayerTrie ¶ added in v0.11.0
type TwoLayerTrie interface { // Start starts the layer one trie Start(context.Context) error // Stop stops the layer one trie Stop(context.Context) error // RootHash returns the layer one trie root RootHash() ([]byte, error) // SetRootHash sets root hash for layer one trie SetRootHash([]byte) error // Get returns the value in layer two Get([]byte, []byte) ([]byte, error) // Upsert upserts an item in layer two Upsert([]byte, []byte, []byte) error // Delete deletes an item in layer two Delete([]byte, []byte) error }
TwoLayerTrie is a trie data structure with two layers
Click to show internal directories.
Click to hide internal directories.