Documentation
¶
Index ¶
- Variables
- func EncodeBytes(w io.Writer, bz []byte) error
- func FindDbsInPath(path string) ([]string, error)
- func NewIngestSnapshotConnection(snapshotDbPath string) (*sqlite3.Conn, error)
- func SetGlobalPruneLimit(n int)
- type Exporter
- type Importer
- type Iterator
- type LeafIterator
- type MultiTree
- func (mt *MultiTree) Close() error
- func (mt *MultiTree) Hash() []byte
- func (mt *MultiTree) LoadVersion(version int64) error
- func (mt *MultiTree) MountTree(storeKey string) error
- func (mt *MultiTree) MountTrees() error
- func (mt *MultiTree) QueryReport(bins int) error
- func (mt *MultiTree) SaveVersion() ([]byte, int64, error)
- func (mt *MultiTree) SaveVersionConcurrently() ([]byte, int64, error)
- func (mt *MultiTree) SetInitialVersion(version int64) error
- func (mt *MultiTree) SnapshotConcurrently() error
- func (mt *MultiTree) WarmLeaves() error
- type Node
- type NodeKey
- type NodePool
- type PathToLeaf
- type ProofInnerNode
- type ProofLeafNode
- type SnapshotNode
- type SnapshotOptions
- type SqliteDb
- func (sql *SqliteDb) Close() error
- func (sql *SqliteDb) GetLatestLeaf(key []byte) (val []byte, topErr error)
- func (sql *SqliteDb) ImportMostRecentSnapshot(targetVersion int64, traverseOrder TraverseOrderType, loadLeaves bool) (root *Node, version int64, topErr error)
- func (sql *SqliteDb) ImportSnapshotFromTable(version int64, traverseOrder TraverseOrderType, loadLeaves bool) (root *Node, topErr error)
- func (sql *SqliteDb) LoadRoot(version int64) (root *Node, topErr error)
- func (sql *SqliteDb) Revert(version int) error
- func (sql *SqliteDb) SaveRoot(version int64, node *Node, isCheckpoint bool) (topErr error)
- func (sql *SqliteDb) Snapshot(ctx context.Context, tree *Tree) (topErr error)
- func (sql *SqliteDb) WarmLeaves() error
- func (sql *SqliteDb) WriteLatestLeaves(tree *Tree) (topErr error)
- func (sql *SqliteDb) WriteSnapshot(ctx context.Context, version int64, nextFn func() (*SnapshotNode, error), ...) (root *Node, topErr error)
- type SqliteDbOptions
- type SqliteKVStore
- type TraverseOrderType
- type Tree
- func (tree *Tree) Close() error
- func (tree *Tree) DeleteVersionsTo(_ int64) error
- func (tree *Tree) Export(version int64, order TraverseOrderType) (*Exporter, error)
- func (tree *Tree) Get(key []byte) ([]byte, error)
- func (tree *Tree) GetByIndex(index int64) (key []byte, value []byte, err error)
- func (tree *Tree) GetProof(version int64, key []byte) (proof *ics23.CommitmentProof, err error)
- func (tree *Tree) GetRecent(version int64, key []byte) (bool, []byte, error)
- func (tree *Tree) GetWithIndex(key []byte) (int64, []byte, error)
- func (tree *Tree) Has(key []byte) (bool, error)
- func (tree *Tree) Hash() []byte
- func (tree *Tree) Height() int8
- func (tree *Tree) Import(version int64) (*Importer, error)
- func (tree *Tree) IterateRecent(version int64, start, end []byte, ascending bool) (bool, Iterator)
- func (tree *Tree) Iterator(start, end []byte, inclusive bool) (itr Iterator, err error)
- func (tree *Tree) LoadSnapshot(version int64, traverseOrder TraverseOrderType) (err error)
- func (tree *Tree) LoadVersion(version int64) (err error)
- func (tree *Tree) NewLeafNode(key []byte, value []byte) *Node
- func (tree *Tree) PathToLeaf(node *Node, key []byte) (PathToLeaf, *Node, error)
- func (tree *Tree) ReadonlyClone() (*Tree, error)
- func (tree *Tree) Remove(key []byte) ([]byte, bool, error)
- func (tree *Tree) ReverseIterator(start, end []byte) (itr Iterator, err error)
- func (tree *Tree) SaveSnapshot() (err error)
- func (tree *Tree) SaveVersion() ([]byte, int64, error)
- func (tree *Tree) Set(key, value []byte) (updated bool, err error)
- func (tree *Tree) SetInitialVersion(version int64) error
- func (tree *Tree) SetShouldCheckpoint()
- func (tree *Tree) Size() int64
- func (tree *Tree) Version() int64
- func (tree *Tree) WorkingBytes() uint64
- func (tree *Tree) WriteLatestLeaves() (err error)
- type TreeIterator
- type TreeOptions
- type VersionRange
- func (r *VersionRange) Add(version int64) error
- func (r *VersionRange) Copy() *VersionRange
- func (r *VersionRange) FindMemoized(version int64) int64
- func (r *VersionRange) FindNext(version int64) int64
- func (r *VersionRange) FindPrevious(version int64) int64
- func (r *VersionRange) FindRecent(version, n int64) int64
- func (r *VersionRange) FindShard(version int64) int64
- func (r *VersionRange) First() int64
- func (r *VersionRange) Last() int64
- func (r *VersionRange) Len() int
- func (r *VersionRange) Remove(version int64)
- func (r *VersionRange) TruncateTo(version int64)
Constants ¶
This section is empty.
Variables ¶
var ErrNoImport = errors.New("no import in progress")
ErrNoImport is returned when calling methods on a closed importer
var ErrorExportDone = fmt.Errorf("export done")
Functions ¶
func FindDbsInPath ¶
func SetGlobalPruneLimit ¶
func SetGlobalPruneLimit(n int)
Types ¶
type Importer ¶
type Importer struct {
// contains filtered or unexported fields
}
Importer imports data into an empty MutableTree. It is created by MutableTree.Import(). Users must call Close() when done.
ExportNodes must be imported in the order returned by Exporter, i.e. depth-first post-order (LRN).
Importer is not concurrency-safe, it is the caller's responsibility to ensure the tree is not modified while performing an import.
func (*Importer) Add ¶
Add adds an ExportNode to the import. ExportNodes must be added in the order returned by Exporter, i.e. depth-first post-order (LRN). Nodes are periodically flushed to the database, but the imported version is not visible until Commit() is called.
type Iterator ¶
type Iterator interface { // Domain returns the start (inclusive) and end (exclusive) limits of the iterator. // CONTRACT: start, end readonly []byte Domain() (start []byte, end []byte) // Valid returns whether the current iterator is valid. Once invalid, the TreeIterator remains // invalid forever. Valid() bool // Next moves the iterator to the next key in the database, as defined by order of iteration. // If Valid returns false, this method will panic. Next() // Key returns the key at the current position. Panics if the iterator is invalid. // CONTRACT: key readonly []byte Key() (key []byte) // Value returns the value at the current position. Panics if the iterator is invalid. // CONTRACT: value readonly []byte Value() (value []byte) // Error returns the last error encountered by the iterator, if any. Error() error // Close closes the iterator, relasing any allocated resources. Close() error }
type LeafIterator ¶
type LeafIterator struct {
// contains filtered or unexported fields
}
func (*LeafIterator) Close ¶
func (l *LeafIterator) Close() error
func (*LeafIterator) Domain ¶
func (l *LeafIterator) Domain() (start []byte, end []byte)
func (*LeafIterator) Error ¶
func (l *LeafIterator) Error() error
func (*LeafIterator) Key ¶
func (l *LeafIterator) Key() (key []byte)
func (*LeafIterator) Next ¶
func (l *LeafIterator) Next()
func (*LeafIterator) Valid ¶
func (l *LeafIterator) Valid() bool
func (*LeafIterator) Value ¶
func (l *LeafIterator) Value() (value []byte)
type MultiTree ¶
MultiTree encapsulates multiple IAVL trees, each with its own "store key" in the context of the Cosmos SDK. Within IAVL v2 is only used to test the IAVL v2 implementation, and for import/export of IAVL v2 state.
func ImportMultiTree ¶
func NewMultiTree ¶
func NewMultiTree(rootPath string, opts TreeOptions) *MultiTree
func (*MultiTree) Hash ¶
Hash is a stand in for code at https://github.com/cosmos/cosmos-sdk/blob/80dd55f79bba8ab675610019a5764470a3e2fef9/store/types/commit_info.go#L30 it used in testing. App chains should use the store hashing code referenced above instead.
func (*MultiTree) LoadVersion ¶
func (*MultiTree) MountTrees ¶
func (*MultiTree) QueryReport ¶
func (*MultiTree) SaveVersionConcurrently ¶
func (*MultiTree) SetInitialVersion ¶
func (*MultiTree) SnapshotConcurrently ¶
func (*MultiTree) WarmLeaves ¶
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node represents a node in a Tree.
func IngestSnapshot ¶
type NodeKey ¶
type NodeKey [12]byte
NodeKey represents a key of node in the DB.
func NewNodeKey ¶
type NodePool ¶
type NodePool struct {
// contains filtered or unexported fields
}
func NewNodePool ¶
func NewNodePool() *NodePool
type PathToLeaf ¶
type PathToLeaf []ProofInnerNode
PathToLeaf represents an inner path to a leaf node. Note that the nodes are ordered such that the last one is closest to the root of the tree.
func (PathToLeaf) String ¶
func (pl PathToLeaf) String() string
type ProofInnerNode ¶
type ProofInnerNode struct { Height int8 `json:"height"` Size int64 `json:"size"` Version int64 `json:"version"` Left []byte `json:"left"` Right []byte `json:"right"` }
func (ProofInnerNode) String ¶
func (pin ProofInnerNode) String() string
type ProofLeafNode ¶
type ProofLeafNode struct { Key []byte `json:"key"` ValueHash []byte `json:"value"` Version int64 `json:"version"` }
func (ProofLeafNode) Hash ¶
func (pln ProofLeafNode) Hash() ([]byte, error)
func (ProofLeafNode) String ¶
func (pln ProofLeafNode) String() string
type SnapshotOptions ¶
type SnapshotOptions struct { StoreLeafValues bool WriteCheckpoint bool DontWriteSnapshot bool TraverseOrder TraverseOrderType }
type SqliteDb ¶
type SqliteDb struct {
// contains filtered or unexported fields
}
func NewInMemorySqliteDb ¶
TODO delete MemoryDb support
NewInMemorySqliteDb probably needs deleting now that the file system is a source of truth for shards. Otherwise shard indexing can be pushed into root.db
func NewSqliteDb ¶
func NewSqliteDb(pool *NodePool, opts SqliteDbOptions) (*SqliteDb, error)
func (*SqliteDb) GetLatestLeaf ¶
func (*SqliteDb) ImportMostRecentSnapshot ¶
func (*SqliteDb) ImportSnapshotFromTable ¶
func (*SqliteDb) WarmLeaves ¶
func (*SqliteDb) WriteLatestLeaves ¶
func (*SqliteDb) WriteSnapshot ¶
func (sql *SqliteDb) WriteSnapshot( ctx context.Context, version int64, nextFn func() (*SnapshotNode, error), opts SnapshotOptions, ) (root *Node, topErr error)
type SqliteDbOptions ¶
type SqliteDbOptions struct { Path string Mode int MmapSize uint64 WalSize int CacheSize int ConnArgs string ShardTrees bool Readonly bool // contains filtered or unexported fields }
func (SqliteDbOptions) EstimateMmapSize ¶
func (opts SqliteDbOptions) EstimateMmapSize() (uint64, error)
type SqliteKVStore ¶
type SqliteKVStore struct {
// contains filtered or unexported fields
}
SqliteKVStore is a generic KV store which uses sqlite as the backend and be used by applications to store and retrieve generic key-value pairs, probably for metadata.
func NewSqliteKVStore ¶
func NewSqliteKVStore(opts SqliteDbOptions) (kv *SqliteKVStore, err error)
func (*SqliteKVStore) Delete ¶
func (kv *SqliteKVStore) Delete(key []byte) error
type TraverseOrderType ¶
type TraverseOrderType uint8
TraverseOrderType is the type of the order in which the tree is traversed.
const ( PreOrder TraverseOrderType = iota PostOrder )
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
func (*Tree) DeleteVersionsTo ¶
func (*Tree) Export ¶
func (tree *Tree) Export(version int64, order TraverseOrderType) (*Exporter, error)
func (*Tree) GetByIndex ¶
func (*Tree) IterateRecent ¶
func (*Tree) LoadSnapshot ¶
func (tree *Tree) LoadSnapshot(version int64, traverseOrder TraverseOrderType) (err error)
func (*Tree) LoadVersion ¶
func (*Tree) NewLeafNode ¶
NewLeafNode returns a new node from a key, value and version.
func (*Tree) PathToLeaf ¶
If the key does not exist, returns the path to the next leaf left of key (w/ path), except when key is less than the least item, in which case it returns a path to the least item.
func (*Tree) ReadonlyClone ¶
func (*Tree) Remove ¶
Remove removes a key from the working tree. The given key byte slice should not be modified after this call, since it may point to data stored inside IAVL.
func (*Tree) ReverseIterator ¶
func (*Tree) SaveSnapshot ¶
func (*Tree) SaveVersion ¶
SaveVersion saves the staged version of the tree to storage. It returns the hash of the root node. Not thread-safe.
func (*Tree) Set ¶
Set sets a key in the working tree. Nil values are invalid. The given key/value byte slices must not be modified after this call, since they point to slices stored within IAVL. It returns true when an existing value was updated, while false means it was a new key.
func (*Tree) SetInitialVersion ¶
func (*Tree) SetShouldCheckpoint ¶
func (tree *Tree) SetShouldCheckpoint()
func (*Tree) WorkingBytes ¶
func (*Tree) WriteLatestLeaves ¶
type TreeIterator ¶
type TreeIterator struct {
// contains filtered or unexported fields
}
func (*TreeIterator) Close ¶
func (i *TreeIterator) Close() error
func (*TreeIterator) Domain ¶
func (i *TreeIterator) Domain() (start []byte, end []byte)
func (*TreeIterator) Error ¶
func (i *TreeIterator) Error() error
func (*TreeIterator) Key ¶
func (i *TreeIterator) Key() (key []byte)
func (*TreeIterator) Next ¶
func (i *TreeIterator) Next()
func (*TreeIterator) Valid ¶
func (i *TreeIterator) Valid() bool
func (*TreeIterator) Value ¶
func (i *TreeIterator) Value() (value []byte)
type TreeOptions ¶
type TreeOptions struct { CheckpointInterval int64 CheckpointMemory uint64 StateStorage bool HeightFilter int8 EvictionDepth int8 MetricsProxy metrics.Proxy PruneRatio float64 MinimumKeepVersions int64 }
func DefaultTreeOptions ¶
func DefaultTreeOptions() TreeOptions
type VersionRange ¶
type VersionRange struct {
// contains filtered or unexported fields
}
func (*VersionRange) Add ¶
func (r *VersionRange) Add(version int64) error
func (*VersionRange) Copy ¶
func (r *VersionRange) Copy() *VersionRange
func (*VersionRange) FindMemoized ¶
func (r *VersionRange) FindMemoized(version int64) int64
func (*VersionRange) FindNext ¶
func (r *VersionRange) FindNext(version int64) int64
func (*VersionRange) FindPrevious ¶
func (r *VersionRange) FindPrevious(version int64) int64
func (*VersionRange) FindRecent ¶
func (r *VersionRange) FindRecent(version, n int64) int64
func (*VersionRange) FindShard ¶
func (r *VersionRange) FindShard(version int64) int64
FindShard returns the shard ID for the given version. It calls FindPrevious, but if version < first shardID it returns the first shardID.
func (*VersionRange) First ¶
func (r *VersionRange) First() int64
func (*VersionRange) Last ¶
func (r *VersionRange) Last() int64
func (*VersionRange) Len ¶
func (r *VersionRange) Len() int
func (*VersionRange) Remove ¶
func (r *VersionRange) Remove(version int64)
func (*VersionRange) TruncateTo ¶
func (r *VersionRange) TruncateTo(version int64)