Documentation ¶
Index ¶
- Constants
- func AddTreePrintTree(edge string, tree treeprint.Tree, rwt KVCallbackIterableReader)
- func CompareKeys(k1, k2 []byte) int
- func EnsureKeyFormatStore(ks interface{}) error
- func KVCallbackIterator(rit KVCallbackIterable, ascending bool, low, high []byte) dbm.Iterator
- func KeyOrder(key []byte) int
- func MarshalCommitID(hash []byte, version int64) ([]byte, error)
- func NormaliseDomain(low, high []byte) ([]byte, []byte)
- func Uniq(source KVIterator) *uniqueIterator
- type ByteSlicable
- type CacheDB
- func (cdb *CacheDB) Close()
- func (cdb *CacheDB) Commit(writer KVWriter)
- func (cdb *CacheDB) Delete(key []byte)
- func (cdb *CacheDB) DeleteSync(key []byte)
- func (cdb *CacheDB) Get(key []byte) []byte
- func (cdb *CacheDB) Has(key []byte) bool
- func (cdb *CacheDB) Iterator(low, high []byte) KVIterator
- func (cdb *CacheDB) NewBatch() dbm.Batch
- func (cdb *CacheDB) Print()
- func (cdb *CacheDB) ReverseIterator(low, high []byte) KVIterator
- func (cdb *CacheDB) Set(key, value []byte)
- func (cdb *CacheDB) SetSync(key, value []byte)
- func (cdb *CacheDB) Stats() map[string]string
- type ChannelIterator
- type CommitID
- type ContentAddressedStore
- type ForestOption
- type ForestReader
- type ImmutableForest
- func (imf *ImmutableForest) Dump() string
- func (imf *ImmutableForest) Iterate(start, end []byte, ascending bool, ...) error
- func (imf *ImmutableForest) IterateRWTree(start, end []byte, ascending bool, fn func(prefix []byte, tree *RWTree) error) error
- func (imf *ImmutableForest) Reader(prefix []byte) (KVCallbackIterableReader, error)
- type ImmutableTree
- type KVCache
- func (kvc *KVCache) Delete(key []byte)
- func (kvc *KVCache) Get(key []byte) []byte
- func (kvc *KVCache) Has(key []byte) bool
- func (kvc *KVCache) Info(key []byte) (value []byte, deleted bool)
- func (kvc *KVCache) Iterator(low, high []byte) KVIterator
- func (kvc *KVCache) Reset()
- func (kvc *KVCache) ReverseIterator(low, high []byte) KVIterator
- func (kvc *KVCache) Set(key, value []byte)
- func (kvc *KVCache) WriteTo(writer KVWriter)
- type KVCacheIterator
- func (kvi *KVCacheIterator) Close()
- func (kvi *KVCacheIterator) Domain() ([]byte, []byte)
- func (kvi *KVCacheIterator) Info() (key, value []byte, deleted bool)
- func (kvi *KVCacheIterator) Key() []byte
- func (kvi *KVCacheIterator) Next()
- func (kvi *KVCacheIterator) Valid() bool
- func (kvi *KVCacheIterator) Value() []byte
- type KVCallbackIterable
- type KVCallbackIterableReader
- type KVCascade
- type KVIterable
- type KVIterableReader
- type KVIterator
- type KVPair
- type KVPairs
- type KVReader
- type KVReaderWriter
- type KVStore
- type KVWriter
- type KeyFormat
- func (kf *KeyFormat) Fix(args ...interface{}) (*KeyFormat, error)
- func (kf *KeyFormat) Iterator(iterable KVIterable, start, end []byte, reverse ...bool) KVIterator
- func (kf *KeyFormat) Key(args ...interface{}) ([]byte, error)
- func (kf *KeyFormat) KeyBytes(segments ...[]byte) ([]byte, error)
- func (kf *KeyFormat) KeyNoPrefix(args ...interface{}) (Prefix, error)
- func (kf *KeyFormat) Layout() []int
- func (kf *KeyFormat) NumSegments() int
- func (kf *KeyFormat) Prefix() Prefix
- func (kf *KeyFormat) Scan(key []byte, args ...interface{}) error
- func (kf *KeyFormat) ScanBytes(key []byte) [][]byte
- func (kf *KeyFormat) ScanNoPrefix(key []byte, args ...interface{}) error
- func (kf *KeyFormat) String() string
- func (kf *KeyFormat) Unprefixed() *KeyFormat
- type MultiIterator
- func (mi *MultiIterator) Close()
- func (mi *MultiIterator) Domain() ([]byte, []byte)
- func (mi *MultiIterator) Key() []byte
- func (mi *MultiIterator) Len() int
- func (mi *MultiIterator) Less(i, j int) bool
- func (mi *MultiIterator) Next()
- func (mi *MultiIterator) Peek() KVIterator
- func (mi *MultiIterator) Pop() interface{}
- func (mi *MultiIterator) Push(x interface{})
- func (mi *MultiIterator) Swap(i, j int)
- func (mi *MultiIterator) Valid() bool
- func (mi *MultiIterator) Value() []byte
- type MustKeyFormat
- func (kf *MustKeyFormat) Fix(args ...interface{}) *MustKeyFormat
- func (kf *MustKeyFormat) Key(args ...interface{}) []byte
- func (kf *MustKeyFormat) KeyBytes(segments ...[]byte) []byte
- func (kf *MustKeyFormat) KeyNoPrefix(args ...interface{}) Prefix
- func (kf *MustKeyFormat) Unprefixed() *MustKeyFormat
- type MutableForest
- func (muf *MutableForest) Delete(prefix []byte) (*CommitID, error)
- func (muf *MutableForest) GetImmutable(version int64) (*ImmutableForest, error)
- func (muf *MutableForest) Hash() []byte
- func (muf *MutableForest) Load(version int64) error
- func (muf *MutableForest) Save() ([]byte, int64, error)
- func (muf *MutableForest) Version() int64
- func (muf *MutableForest) Writer(prefix []byte) (*RWTree, error)
- type MutableTree
- func (mut *MutableTree) Get(key []byte) []byte
- func (mut *MutableTree) GetImmutable(version int64) (*ImmutableTree, error)
- func (mut *MutableTree) Iterate(start, end []byte, ascending bool, fn func(key []byte, value []byte) error) error
- func (mut *MutableTree) IterateWriteTree(start, end []byte, ascending bool, fn func(key []byte, value []byte) error) error
- func (mut *MutableTree) Load(version int64, overwriting bool) error
- type Prefix
- func (p Prefix) Above() []byte
- func (p Prefix) Below() []byte
- func (p Prefix) CallbackIterable(source KVCallbackIterable) *prefixCallbackIterable
- func (p Prefix) HexString() string
- func (p Prefix) Iterable(source KVIterable) KVIterable
- func (p Prefix) Iterator(iteratorFn func(start, end []byte) dbm.Iterator, start, end []byte) KVIterator
- func (p Prefix) Key(key []byte) []byte
- func (p Prefix) Length() int
- func (p Prefix) Store(source KVStore) KVStore
- func (p Prefix) String() string
- func (p Prefix) Suffix(key []byte) []byte
- type PrefixDB
- func (pdb *PrefixDB) Close()
- func (pdb *PrefixDB) Delete(key []byte)
- func (pdb *PrefixDB) DeleteSync(key []byte)
- func (pdb *PrefixDB) Get(key []byte) []byte
- func (pdb *PrefixDB) Has(key []byte) bool
- func (pdb *PrefixDB) Iterator(low, high []byte) KVIterator
- func (pdb *PrefixDB) NewBatch() dbm.Batch
- func (pdb *PrefixDB) Print()
- func (pdb *PrefixDB) ReverseIterator(low, high []byte) KVIterator
- func (pdb *PrefixDB) Set(key, value []byte)
- func (pdb *PrefixDB) SetSync(key, value []byte)
- func (pdb *PrefixDB) Stats() map[string]string
- type RWTree
- func (rwt *RWTree) Delete(key []byte) ([]byte, bool)
- func (rwt *RWTree) Dump() string
- func (rwt *RWTree) GetImmutable(version int64) (*ImmutableTree, error)
- func (rwt *RWTree) IterateWriteTree(start, end []byte, ascending bool, fn func(key []byte, value []byte) error) error
- func (rwt *RWTree) Load(version int64, overwriting bool) error
- func (rwt *RWTree) Save() ([]byte, int64, error)
- func (rwt *RWTree) Set(key, value []byte) bool
- func (rwt *RWTree) Updated() bool
- type Trie
- type TrieNode
Constants ¶
const ( DelimiterSegmentLength = -1 VariadicSegmentLength = 0 )
Variables ¶
This section is empty.
Functions ¶
func AddTreePrintTree ¶ added in v0.24.0
func AddTreePrintTree(edge string, tree treeprint.Tree, rwt KVCallbackIterableReader)
func CompareKeys ¶
Sorts the keys as if they were compared lexicographically with their KeyOrder prepended
func EnsureKeyFormatStore ¶ added in v0.24.0
func EnsureKeyFormatStore(ks interface{}) error
func KVCallbackIterator ¶ added in v0.24.0
func KVCallbackIterator(rit KVCallbackIterable, ascending bool, low, high []byte) dbm.Iterator
func KeyOrder ¶
KeyOrder maps []byte{} -> -1, []byte(nil) -> 1, and everything else to 0. This encodes the assumptions of the KVIterator domain endpoints
func MarshalCommitID ¶ added in v0.24.0
func NormaliseDomain ¶
NormaliseDomain encodes the assumption that when nil is used as a lower bound is interpreted as low rather than high
func Uniq ¶
func Uniq(source KVIterator) *uniqueIterator
Types ¶
type ByteSlicable ¶
type ByteSlicable interface {
Bytes() []byte
}
type CacheDB ¶
type CacheDB struct {
// contains filtered or unexported fields
}
func NewCacheDB ¶
func NewCacheDB(backend KVIterableReader) *CacheDB
func (*CacheDB) DeleteSync ¶
func (*CacheDB) Iterator ¶
func (cdb *CacheDB) Iterator(low, high []byte) KVIterator
func (*CacheDB) ReverseIterator ¶
func (cdb *CacheDB) ReverseIterator(low, high []byte) KVIterator
type ChannelIterator ¶
type ChannelIterator struct {
// contains filtered or unexported fields
}
func NewChannelIterator ¶
func NewChannelIterator(ch <-chan KVPair, start, end []byte) *ChannelIterator
ChannelIterator wraps a stream of kvp KVPairs over a channel as a stateful KVIterator. The start and end keys provided are purely indicative (for Domain()) and are assumed to be honoured by the input channel - they are not checked and keys are not sorted. NewChannelIterator will block until the first value is received over the channel.
func (*ChannelIterator) Close ¶
func (it *ChannelIterator) Close()
func (*ChannelIterator) Domain ¶
func (it *ChannelIterator) Domain() ([]byte, []byte)
func (*ChannelIterator) Key ¶
func (it *ChannelIterator) Key() []byte
func (*ChannelIterator) Next ¶
func (it *ChannelIterator) Next()
func (*ChannelIterator) Valid ¶
func (it *ChannelIterator) Valid() bool
func (*ChannelIterator) Value ¶
func (it *ChannelIterator) Value() []byte
type CommitID ¶ added in v0.24.0
func UnmarshalCommitID ¶ added in v0.24.0
type ContentAddressedStore ¶
type ContentAddressedStore struct {
// contains filtered or unexported fields
}
func NewContentAddressedStore ¶
func NewContentAddressedStore(db dbm.DB) *ContentAddressedStore
type ForestOption ¶ added in v0.24.0
type ForestOption func(*ImmutableForest)
var WithOverwriting ForestOption = func(imf *ImmutableForest) { imf.overwriting = true }
type ForestReader ¶ added in v0.24.0
type ForestReader interface {
Reader(prefix []byte) (KVCallbackIterableReader, error)
}
type ImmutableForest ¶ added in v0.24.0
type ImmutableForest struct {
// contains filtered or unexported fields
}
func NewImmutableForest ¶ added in v0.24.0
func NewImmutableForest(commitsTree KVCallbackIterableReader, treeDB dbm.DB, cacheSize int, options ...ForestOption) (*ImmutableForest, error)
func (*ImmutableForest) Dump ¶ added in v0.24.0
func (imf *ImmutableForest) Dump() string
func (*ImmutableForest) Iterate ¶ added in v0.24.0
func (imf *ImmutableForest) Iterate(start, end []byte, ascending bool, fn func(prefix []byte, tree KVCallbackIterableReader) error) error
func (*ImmutableForest) IterateRWTree ¶ added in v0.24.0
func (*ImmutableForest) Reader ¶ added in v0.24.0
func (imf *ImmutableForest) Reader(prefix []byte) (KVCallbackIterableReader, error)
Get the tree at prefix for making reads
type ImmutableTree ¶ added in v0.24.0
type ImmutableTree struct {
*iavl.ImmutableTree
}
func (*ImmutableTree) Get ¶ added in v0.24.0
func (imt *ImmutableTree) Get(key []byte) []byte
type KVCache ¶
func NewKVCache ¶
func NewKVCache() *KVCache
Creates an in-memory cache wrapping a map that stores the provided tombstone value for deleted keys
func (*KVCache) Iterator ¶
func (kvc *KVCache) Iterator(low, high []byte) KVIterator
func (*KVCache) ReverseIterator ¶
func (kvc *KVCache) ReverseIterator(low, high []byte) KVIterator
type KVCacheIterator ¶
type KVCacheIterator struct {
// contains filtered or unexported fields
}
func (*KVCacheIterator) Close ¶
func (kvi *KVCacheIterator) Close()
func (*KVCacheIterator) Domain ¶
func (kvi *KVCacheIterator) Domain() ([]byte, []byte)
func (*KVCacheIterator) Info ¶
func (kvi *KVCacheIterator) Info() (key, value []byte, deleted bool)
func (*KVCacheIterator) Key ¶
func (kvi *KVCacheIterator) Key() []byte
func (*KVCacheIterator) Next ¶
func (kvi *KVCacheIterator) Next()
func (*KVCacheIterator) Valid ¶
func (kvi *KVCacheIterator) Valid() bool
func (*KVCacheIterator) Value ¶
func (kvi *KVCacheIterator) Value() []byte
type KVCallbackIterable ¶ added in v0.24.0
type KVCallbackIterable interface { // low must be lexicographically less than high. high is exclusive unless it is nil in which case it is inclusive. // ascending == false reverses order. Iterate(low, high []byte, ascending bool, fn func(key []byte, value []byte) error) error }
Provides the native iteration for IAVLTree
type KVCallbackIterableReader ¶ added in v0.24.0
type KVCallbackIterableReader interface { KVReader KVCallbackIterable }
type KVCascade ¶
type KVCascade []KVIterableReader
func (KVCascade) Iterator ¶
func (kvc KVCascade) Iterator(low, high []byte) KVIterator
func (KVCascade) ReverseIterator ¶
func (kvc KVCascade) ReverseIterator(low, high []byte) KVIterator
type KVIterable ¶
type KVIterable interface { // Iterator over a domain of keys in ascending order. high is exclusive. // low must be less than high, or the Iterator is invalid. // Iterator must be closed by caller. // To iterate over entire domain, use store.Iterator(nil, nil) // CONTRACT: No writes may happen within a domain while an iterator exists over it. Iterator(low, high []byte) KVIterator // Iterator over a domain of keys in descending order. high is exclusive. // must be less than high, or the Iterator is invalid. // Iterator must be closed by caller. // CONTRACT: No writes may happen within a domain while an iterator exists over it. ReverseIterator(low, high []byte) KVIterator }
This is partially extrated from Cosmos SDK for alignment but is more minimal, we should suggest this becomes an embedded interface
type KVIterableReader ¶
type KVIterableReader interface { KVReader KVIterable }
type KVIterator ¶
type KVReaderWriter ¶
KVStore is a simple interface to get/set data
type KVStore ¶
type KVStore interface { KVReaderWriter KVIterable }
type KeyFormat ¶
type KeyFormat struct {
// contains filtered or unexported fields
}
Provides a fixed-width lexicographically sortable []byte key format
func NewKeyFormat ¶
Create a []byte key format based on a single byte prefix and fixed width key segments each of whose length is specified by by the corresponding element of layout. A final segment length of 0 can be used to indicate a variadic final element that may be of arbitrary length.
For example, to store keys that could index some objects by a version number and their SHA256 hash using the form: 'c<version uint64><hash [32]byte>' then you would define the KeyFormat with:
var keyFormat = NewKeyFormat('c', 8, 32)
Then you can create a key with:
func ObjectKey(version uint64, objectBytes []byte) []byte { hasher := sha256.New() hasher.Sum(nil) return keyFormat.Key(version, hasher.Sum(nil)) }}
func (*KeyFormat) Fix ¶
Fixes the first args many segments as the prefix of a new KeyFormat by using the args to generate a key that becomes that prefix. Any remaining unassigned segments become the layout of the new KeyFormat.
func (*KeyFormat) Iterator ¶
func (kf *KeyFormat) Iterator(iterable KVIterable, start, end []byte, reverse ...bool) KVIterator
Returns an iterator over the underlying iterable using this KeyFormat's prefix. This is to support proper iteration over the prefix in the presence of nil start or end which requests iteration to the inclusive edges of the domain. An optional argument for reverse can be passed to get reverse iteration.
func (*KeyFormat) Key ¶
Format the args passed into the key format - will panic if the arguments passed do not match the length of the segment to which they correspond. When called with no arguments returns the raw prefix (useful as a start element of the entire keys space when sorted lexicographically).
func (*KeyFormat) KeyBytes ¶
Format the byte segments into the key format - will panic if the segment lengths do not match the layout.
func (*KeyFormat) KeyNoPrefix ¶ added in v0.24.0
Like Key but removes the prefix string
func (*KeyFormat) NumSegments ¶
func (*KeyFormat) Prefix ¶
Return the Key as a prefix - may just be the literal prefix, or an entire key
func (*KeyFormat) Scan ¶
Extracts the segments into the values pointed to by each of args. Each arg must be a pointer to int64, uint64, or []byte, and the width of the args must match layout.
func (*KeyFormat) ScanBytes ¶
Reads out the bytes associated with each segment of the key format from key.
func (*KeyFormat) ScanNoPrefix ¶ added in v0.24.0
Like Scan but adds expects a key with the KeyFormat's prefix trimmed
func (*KeyFormat) Unprefixed ¶
type MultiIterator ¶
type MultiIterator struct {
// contains filtered or unexported fields
}
func NewMultiIterator ¶
func NewMultiIterator(reverse bool, iterators ...KVIterator) *MultiIterator
MultiIterator iterates in order over a series o
func (*MultiIterator) Close ¶
func (mi *MultiIterator) Close()
func (*MultiIterator) Domain ¶
func (mi *MultiIterator) Domain() ([]byte, []byte)
func (*MultiIterator) Key ¶
func (mi *MultiIterator) Key() []byte
func (*MultiIterator) Less ¶
func (mi *MultiIterator) Less(i, j int) bool
func (*MultiIterator) Next ¶
func (mi *MultiIterator) Next()
func (*MultiIterator) Peek ¶
func (mi *MultiIterator) Peek() KVIterator
func (*MultiIterator) Pop ¶
func (mi *MultiIterator) Pop() interface{}
func (*MultiIterator) Push ¶
func (mi *MultiIterator) Push(x interface{})
func (*MultiIterator) Swap ¶
func (mi *MultiIterator) Swap(i, j int)
func (*MultiIterator) Valid ¶
func (mi *MultiIterator) Valid() bool
func (*MultiIterator) Value ¶
func (mi *MultiIterator) Value() []byte
type MustKeyFormat ¶
type MustKeyFormat struct {
KeyFormat
}
MustKeyFormat for panicking early when a KeyFormat does not parse
func NewMustKeyFormat ¶
func NewMustKeyFormat(prefix string, layout ...int) *MustKeyFormat
func (*MustKeyFormat) Fix ¶
func (kf *MustKeyFormat) Fix(args ...interface{}) *MustKeyFormat
func (*MustKeyFormat) Key ¶
func (kf *MustKeyFormat) Key(args ...interface{}) []byte
func (*MustKeyFormat) KeyBytes ¶
func (kf *MustKeyFormat) KeyBytes(segments ...[]byte) []byte
func (*MustKeyFormat) KeyNoPrefix ¶ added in v0.24.0
func (kf *MustKeyFormat) KeyNoPrefix(args ...interface{}) Prefix
func (*MustKeyFormat) Unprefixed ¶ added in v0.24.0
func (kf *MustKeyFormat) Unprefixed() *MustKeyFormat
type MutableForest ¶ added in v0.24.0
type MutableForest struct { *ImmutableForest // contains filtered or unexported fields }
func NewMutableForest ¶ added in v0.24.0
func NewMutableForest(db dbm.DB, cacheSize int) (*MutableForest, error)
func (*MutableForest) Delete ¶ added in v0.24.0
func (muf *MutableForest) Delete(prefix []byte) (*CommitID, error)
Delete a tree - if the tree exists will return the CommitID of the latest saved version
func (*MutableForest) GetImmutable ¶ added in v0.24.0
func (muf *MutableForest) GetImmutable(version int64) (*ImmutableForest, error)
func (*MutableForest) Hash ¶ added in v0.24.0
func (muf *MutableForest) Hash() []byte
Get the current global hash for all trees in this forest
func (*MutableForest) Load ¶ added in v0.24.0
func (muf *MutableForest) Load(version int64) error
Load mutable forest from database, pass overwriting = true if you wish to make writes to version version + 1. this will
func (*MutableForest) Save ¶ added in v0.24.0
func (muf *MutableForest) Save() ([]byte, int64, error)
func (*MutableForest) Version ¶ added in v0.24.0
func (muf *MutableForest) Version() int64
Get the current global version for all versions of all trees in this forest
type MutableTree ¶ added in v0.24.0
type MutableTree struct {
*iavl.MutableTree
}
func NewMutableTree ¶ added in v0.24.0
func NewMutableTree(db dbm.DB, cacheSize int) *MutableTree
func (*MutableTree) Get ¶ added in v0.24.0
func (mut *MutableTree) Get(key []byte) []byte
func (*MutableTree) GetImmutable ¶ added in v0.24.0
func (mut *MutableTree) GetImmutable(version int64) (*ImmutableTree, error)
func (*MutableTree) IterateWriteTree ¶ added in v0.24.0
type Prefix ¶
type Prefix []byte
func (Prefix) Above ¶
Get the lexicographical sibling above this prefix (i.e. the fixed length integer plus one)
func (Prefix) Below ¶
Get the lexicographical sibling below this prefix (i.e. the fixed length integer minus one)
func (Prefix) CallbackIterable ¶ added in v0.24.0
func (p Prefix) CallbackIterable(source KVCallbackIterable) *prefixCallbackIterable
func (Prefix) Iterable ¶
func (p Prefix) Iterable(source KVIterable) KVIterable
type PrefixDB ¶
type PrefixDB struct {
// contains filtered or unexported fields
}
func (*PrefixDB) DeleteSync ¶
func (*PrefixDB) Iterator ¶
func (pdb *PrefixDB) Iterator(low, high []byte) KVIterator
func (*PrefixDB) ReverseIterator ¶
func (pdb *PrefixDB) ReverseIterator(low, high []byte) KVIterator
type RWTree ¶
type RWTree struct { // Read-only tree serving previous state *ImmutableTree // contains filtered or unexported fields }
func NewRWTree ¶
Creates a concurrency safe version of an IAVL tree whereby reads are routed to the last saved tree. Writes must be serialised (as they are within a commit for example).
func (*RWTree) GetImmutable ¶ added in v0.24.0
func (rwt *RWTree) GetImmutable(version int64) (*ImmutableTree, error)
func (*RWTree) IterateWriteTree ¶ added in v0.24.0
func (*RWTree) Load ¶
Tries to load the execution state from DB, returns nil with no error if no state found