Documentation ¶
Index ¶
- Constants
- func EncodeBytes(w io.Writer, bz []byte) error
- func GetLatestVersion(dir string) (int64, error)
- func HashNode(node Node) []byte
- func Mmap(f *os.File) ([]byte, *[mmap.MaxMapSize]byte, error)
- func VerifyHash(node Node) bool
- func WriteFileSync(name string, data []byte) error
- type DB
- func (db *DB) ApplyChangeSet(name string, changeSet iavl.ChangeSet) error
- func (db *DB) ApplyChangeSets(changeSets []*proto.NamedChangeSet) error
- func (db *DB) ApplyUpgrades(upgrades []*proto.TreeNameUpgrade) error
- func (db *DB) Close() error
- func (db *DB) Commit() (int64, error)
- func (db *DB) CommittedVersion() (int64, error)
- func (db *DB) Copy() *DB
- func (db *DB) LastCommitInfo() *proto.CommitInfo
- func (db *DB) ReadOnly() bool
- func (db *DB) Reload() error
- func (db *DB) RewriteSnapshot(ctx context.Context) error
- func (db *DB) RewriteSnapshotBackground() error
- func (db *DB) SaveVersion(updateCommitInfo bool) (int64, error)
- func (db *DB) SetInitialVersion(initialVersion int64) error
- func (db *DB) TreeByName(name string) *Tree
- func (db *DB) UpdateCommitInfo()
- func (db *DB) Version() int64
- func (db *DB) WorkingCommitInfo() *proto.CommitInfo
- func (db *DB) WriteSnapshot(dir string) error
- type Exporter
- type FileLock
- type Iterator
- type LeafLayout
- type Leaves
- type MemNode
- func (node *MemNode) Get(key []byte) ([]byte, uint32)
- func (node *MemNode) GetByIndex(index uint32) ([]byte, []byte)
- func (node *MemNode) Hash() []byte
- func (node *MemNode) Height() uint8
- func (node *MemNode) IsLeaf() bool
- func (node *MemNode) Key() []byte
- func (node *MemNode) Left() Node
- func (node *MemNode) Mutate(version, cowVersion uint32) *MemNode
- func (node *MemNode) Right() Node
- func (node *MemNode) SafeHash() []byte
- func (node *MemNode) Size() int64
- func (node *MemNode) Value() []byte
- func (node *MemNode) Version() uint32
- type MmapFile
- type MultiTree
- func (t *MultiTree) ApplyChangeSet(name string, changeSet iavl.ChangeSet) error
- func (t *MultiTree) ApplyChangeSets(changeSets []*proto.NamedChangeSet) error
- func (t *MultiTree) ApplyUpgrades(upgrades []*proto.TreeNameUpgrade) error
- func (t *MultiTree) Catchup(stream types.Stream[proto.ChangelogEntry], endVersion int64) error
- func (t *MultiTree) Close() error
- func (t *MultiTree) Copy(cacheSize int) *MultiTree
- func (t *MultiTree) LastCommitInfo() *proto.CommitInfo
- func (t *MultiTree) ReplaceWith(other *MultiTree) error
- func (t *MultiTree) SaveVersion(updateCommitInfo bool) (int64, error)
- func (t *MultiTree) SetInitialVersion(initialVersion int64) error
- func (t *MultiTree) SetZeroCopy(zeroCopy bool)
- func (t *MultiTree) SnapshotVersion() int64
- func (t *MultiTree) TreeByName(name string) *Tree
- func (t *MultiTree) Trees() []NamedTree
- func (t *MultiTree) UpdateCommitInfo()
- func (t *MultiTree) Version() int64
- func (t *MultiTree) WorkingCommitInfo() *proto.CommitInfo
- func (t *MultiTree) WriteSnapshot(ctx context.Context, dir string, wp *pond.WorkerPool) error
- type MultiTreeExporter
- type MultiTreeImporter
- type NamedTree
- type Node
- type NodeLayout
- type Nodes
- type Options
- type PersistedNode
- func (node PersistedNode) Get(key []byte) ([]byte, uint32)
- func (node PersistedNode) GetByIndex(leafIndex uint32) ([]byte, []byte)
- func (node PersistedNode) Hash() []byte
- func (node PersistedNode) Height() uint8
- func (node PersistedNode) IsLeaf() bool
- func (node PersistedNode) Key() []byte
- func (node PersistedNode) Left() Node
- func (node PersistedNode) Mutate(version, _ uint32) *MemNode
- func (node PersistedNode) Right() Node
- func (node PersistedNode) SafeHash() []byte
- func (node PersistedNode) Size() int64
- func (node PersistedNode) Value() []byte
- func (node PersistedNode) Version() uint32
- type Snapshot
- func (snapshot *Snapshot) Close() error
- func (snapshot *Snapshot) Export() *Exporter
- func (snapshot *Snapshot) IsEmpty() bool
- func (snapshot *Snapshot) Key(offset uint64) []byte
- func (snapshot *Snapshot) KeyValue(offset uint64) ([]byte, []byte)
- func (snapshot *Snapshot) Leaf(index uint32) PersistedNode
- func (snapshot *Snapshot) LeafKey(index uint32) []byte
- func (snapshot *Snapshot) LeafKeyValue(index uint32) ([]byte, []byte)
- func (snapshot *Snapshot) Node(index uint32) PersistedNode
- func (snapshot *Snapshot) RootHash() []byte
- func (snapshot *Snapshot) RootNode() PersistedNode
- func (snapshot *Snapshot) ScanNodes(callback func(node PersistedNode) error) error
- func (snapshot *Snapshot) Version() uint32
- type Tree
- func (t *Tree) ApplyChangeSet(changeSet iavl.ChangeSet)
- func (t *Tree) Close() error
- func (t *Tree) Copy(_ int) *Tree
- func (t *Tree) Export() *Exporter
- func (t *Tree) Get(key []byte) []byte
- func (t *Tree) GetByIndex(index int64) ([]byte, []byte)
- func (t *Tree) GetMembershipProof(key []byte) (*ics23.CommitmentProof, error)
- func (t *Tree) GetNonMembershipProof(key []byte) (*ics23.CommitmentProof, error)
- func (t *Tree) GetProof(key []byte) *ics23.CommitmentProof
- func (t *Tree) GetWithIndex(key []byte) (int64, []byte)
- func (t *Tree) Has(key []byte) bool
- func (t *Tree) IsEmpty() bool
- func (t *Tree) Iterator(start, end []byte, ascending bool) dbm.Iterator
- func (t *Tree) Remove(key []byte)
- func (t *Tree) ReplaceWith(other *Tree) error
- func (t *Tree) RootHash() []byte
- func (t *Tree) SaveVersion(updateHash bool) ([]byte, int64, error)
- func (t *Tree) ScanPostOrder(callback func(node Node) bool)
- func (t *Tree) Set(key, value []byte)
- func (t *Tree) SetInitialVersion(initialVersion int64) error
- func (t *Tree) SetZeroCopy(zeroCopy bool)
- func (t *Tree) VerifyMembership(proof *ics23.CommitmentProof, key []byte) bool
- func (t *Tree) VerifyNonMembership(proof *ics23.CommitmentProof, key []byte) bool
- func (t *Tree) Version() int64
- func (t *Tree) WriteSnapshot(ctx context.Context, snapshotDir string) error
- type TreeImporter
Constants ¶
const ( SnapshotPrefix = "snapshot-" SnapshotDirLen = len(SnapshotPrefix) + 20 )
const ( OffsetHeight = 0 OffsetPreTrees = OffsetHeight + 1 OffsetVersion = OffsetHeight + 4 OffsetSize = OffsetVersion + 4 OffsetKeyLeaf = OffsetSize + 4 OffsetHash = OffsetKeyLeaf + 4 SizeHash = sha256.Size SizeNodeWithoutHash = OffsetHash SizeNode = SizeNodeWithoutHash + SizeHash OffsetLeafVersion = 0 OffsetLeafKeyLen = OffsetLeafVersion + 4 OffsetLeafKeyOffset = OffsetLeafKeyLen + 4 OffsetLeafHash = OffsetLeafKeyOffset + 8 SizeLeafWithoutHash = OffsetLeafHash SizeLeaf = SizeLeafWithoutHash + SizeHash )
const ( // SnapshotFileMagic is little endian encoded b"IAVL" SnapshotFileMagic = 1280721225 // the initial snapshot format SnapshotFormat = 0 // magic: uint32, format: uint32, version: uint32 SizeMetadata = 12 FileNameNodes = "nodes" FileNameLeaves = "leaves" FileNameKVs = "kvs" FileNameMetadata = "metadata" )
const LockFileName = "LOCK"
const MetadataFileName = "__metadata"
Variables ¶
This section is empty.
Functions ¶
func EncodeBytes ¶ added in v0.0.23
EncodeBytes writes a varint length-prefixed byte slice to the writer, it's used for hash computation, must be compactible with the official IAVL implementation.
func GetLatestVersion ¶ added in v0.0.23
GetLatestVersion finds the latest version number without loading the whole db, it's needed for upgrade module to check store upgrades, it returns 0 if db doesn't exist or is empty.
func VerifyHash ¶ added in v0.0.23
VerifyHash compare node's cached hash with computed one
func WriteFileSync ¶ added in v0.0.23
WriteFileSync calls `f.Sync` after before closing the file
Types ¶
type DB ¶ added in v0.0.23
type DB struct { MultiTree // contains filtered or unexported fields }
DB implements DB-like functionalities on top of MultiTree: - async snapshot rewriting - Write-ahead-log
The memiavl.db directory looks like this: ``` > current -> snapshot-N > snapshot-N > bank > kvs > nodes > metadata > acc > ... other stores > rlog ```
func (*DB) ApplyChangeSet ¶ added in v0.0.23
ApplyChangeSet wraps MultiTree.ApplyChangeSet, it also appends the changesets in the pending log, which will be persisted to the rlog in next Commit call.
func (*DB) ApplyChangeSets ¶ added in v0.0.23
func (db *DB) ApplyChangeSets(changeSets []*proto.NamedChangeSet) error
ApplyChangeSets wraps MultiTree.ApplyChangeSets, it also appends the changesets in the pending log, which will be persisted to the rlog in next Commit call.
func (*DB) ApplyUpgrades ¶ added in v0.0.23
func (db *DB) ApplyUpgrades(upgrades []*proto.TreeNameUpgrade) error
ApplyUpgrades wraps MultiTree.ApplyUpgrades, it also appends the upgrades in a pending log, which will be persisted to the rlog in next Commit call.
func (*DB) Commit ¶ added in v0.0.23
Commit wraps SaveVersion to bump the version and writes the pending changes into log files to persist on disk
func (*DB) CommittedVersion ¶ added in v0.0.23
CommittedVersion returns the latest version written in rlog file, or snapshot version if rlog is empty.
func (*DB) LastCommitInfo ¶ added in v0.0.23
func (db *DB) LastCommitInfo() *proto.CommitInfo
LastCommitInfo returns the last commit info.
func (*DB) RewriteSnapshot ¶ added in v0.0.23
RewriteSnapshot writes the current version of memiavl into a snapshot, and update the `current` symlink.
func (*DB) RewriteSnapshotBackground ¶ added in v0.0.23
RewriteSnapshotBackground rewrite snapshot in a background goroutine, `Commit` will check the complete status, and switch to the new snapshot.
func (*DB) SaveVersion ¶ added in v0.0.23
func (*DB) SetInitialVersion ¶ added in v0.0.23
SetInitialVersion wraps `MultiTree.SetInitialVersion`. it will do a snapshot rewrite, because we can't use rlog to record this change, we need it to convert versions to rlog index in the first place.
func (*DB) TreeByName ¶ added in v0.0.23
TreeByName wraps MultiTree.TreeByName to add a lock.
func (*DB) UpdateCommitInfo ¶ added in v0.0.23
func (db *DB) UpdateCommitInfo()
UpdateCommitInfo wraps MultiTree.UpdateCommitInfo to add a lock.
func (*DB) WorkingCommitInfo ¶ added in v0.0.23
func (db *DB) WorkingCommitInfo() *proto.CommitInfo
func (*DB) WriteSnapshot ¶ added in v0.0.23
WriteSnapshot wraps MultiTree.WriteSnapshot to add a lock.
type Exporter ¶ added in v0.0.23
type Exporter struct {
// contains filtered or unexported fields
}
type Iterator ¶ added in v0.0.23
type Iterator struct {
// contains filtered or unexported fields
}
func NewIterator ¶ added in v0.0.23
type LeafLayout ¶ added in v0.0.23
type LeafLayout struct {
// contains filtered or unexported fields
}
func (LeafLayout) Hash ¶ added in v0.0.23
func (leaf LeafLayout) Hash() []byte
func (LeafLayout) KeyLength ¶ added in v0.0.23
func (leaf LeafLayout) KeyLength() uint32
func (LeafLayout) KeyOffset ¶ added in v0.0.23
func (leaf LeafLayout) KeyOffset() uint64
func (LeafLayout) Version ¶ added in v0.0.23
func (leaf LeafLayout) Version() uint32
type Leaves ¶ added in v0.0.23
type Leaves struct {
// contains filtered or unexported fields
}
Leaves is a continuously stored IAVL nodes
func (Leaves) Leaf ¶ added in v0.0.23
func (leaves Leaves) Leaf(i uint32) LeafLayout
type MemNode ¶ added in v0.0.23
type MemNode struct {
// contains filtered or unexported fields
}
func (*MemNode) GetByIndex ¶ added in v0.0.23
func (*MemNode) Hash ¶ added in v0.0.23
Computes the hash of the node without computing its descendants. Must be called on nodes which have descendant node hashes already computed.
type MmapFile ¶ added in v0.0.23
type MmapFile struct {
// contains filtered or unexported fields
}
MmapFile manage the resources of a mmap-ed file
func NewMmap ¶ added in v0.0.23
Open openes the file and create the mmap. the mmap is created with flags: PROT_READ, MAP_SHARED, MADV_RANDOM.
type MultiTree ¶ added in v0.0.23
type MultiTree struct {
// contains filtered or unexported fields
}
MultiTree manages multiple memiavl tree together, all the trees share the same latest version, the snapshots are always created at the same version.
The snapshot structure is like this: ``` > snapshot-V > metadata > bank > kvs > nodes > metadata > acc > other stores... ```
func LoadMultiTree ¶ added in v0.0.23
func NewEmptyMultiTree ¶ added in v0.0.23
func (*MultiTree) ApplyChangeSet ¶ added in v0.0.23
ApplyChangeSet applies change set for a single tree.
func (*MultiTree) ApplyChangeSets ¶ added in v0.0.23
func (t *MultiTree) ApplyChangeSets(changeSets []*proto.NamedChangeSet) error
ApplyChangeSets applies change sets for multiple trees.
func (*MultiTree) ApplyUpgrades ¶ added in v0.0.23
func (t *MultiTree) ApplyUpgrades(upgrades []*proto.TreeNameUpgrade) error
ApplyUpgrades store name upgrades
func (*MultiTree) Catchup ¶ added in v0.0.23
Catchup replay the new entries in the Rlog file on the tree to catch up to the target or latest version.
func (*MultiTree) Copy ¶ added in v0.0.23
Copy returns a snapshot of the tree which won't be corrupted by further modifications on the main tree.
func (*MultiTree) LastCommitInfo ¶ added in v0.0.23
func (t *MultiTree) LastCommitInfo() *proto.CommitInfo
func (*MultiTree) ReplaceWith ¶ added in v0.0.29
func (*MultiTree) SaveVersion ¶ added in v0.0.23
SaveVersion bumps the versions of all the stores and optionally returns the new app hash
func (*MultiTree) SetInitialVersion ¶ added in v0.0.23
func (*MultiTree) SetZeroCopy ¶ added in v0.0.23
func (*MultiTree) SnapshotVersion ¶ added in v0.0.23
func (*MultiTree) TreeByName ¶ added in v0.0.23
TreeByName returns the tree by name, returns nil if not found
func (*MultiTree) Trees ¶ added in v0.0.23
Trees returns all the trees together with the name, ordered by name.
func (*MultiTree) UpdateCommitInfo ¶ added in v0.0.23
func (t *MultiTree) UpdateCommitInfo()
UpdateCommitInfo update lastCommitInfo based on current status of trees. it's needed if `updateCommitInfo` is set to `false` in `ApplyChangeSet`.
func (*MultiTree) WorkingCommitInfo ¶ added in v0.0.23
func (t *MultiTree) WorkingCommitInfo() *proto.CommitInfo
WorkingCommitInfo returns the commit info for the working tree
func (*MultiTree) WriteSnapshot ¶ added in v0.0.23
type MultiTreeExporter ¶ added in v0.0.23
type MultiTreeExporter struct {
// contains filtered or unexported fields
}
func NewMultiTreeExporter ¶ added in v0.0.23
func NewMultiTreeExporter(dir string, version uint32, supportExportNonSnapshotVersion bool) (exporter *MultiTreeExporter, err error)
func (*MultiTreeExporter) Close ¶ added in v0.0.23
func (mte *MultiTreeExporter) Close() error
func (*MultiTreeExporter) Next ¶ added in v0.0.23
func (mte *MultiTreeExporter) Next() (interface{}, error)
type MultiTreeImporter ¶ added in v0.0.23
type MultiTreeImporter struct {
// contains filtered or unexported fields
}
func NewMultiTreeImporter ¶ added in v0.0.23
func NewMultiTreeImporter(dir string, height uint64) (*MultiTreeImporter, error)
func (*MultiTreeImporter) Add ¶ added in v0.0.23
func (mti *MultiTreeImporter) Add(item interface{}) error
func (*MultiTreeImporter) AddNode ¶ added in v0.0.23
func (mti *MultiTreeImporter) AddNode(node *types.SnapshotNode)
func (*MultiTreeImporter) AddTree ¶ added in v0.0.23
func (mti *MultiTreeImporter) AddTree(name string) error
func (*MultiTreeImporter) Close ¶ added in v0.0.23
func (mti *MultiTreeImporter) Close() error
type Node ¶ added in v0.0.23
type Node interface { Height() uint8 IsLeaf() bool Size() int64 Version() uint32 Key() []byte Value() []byte Left() Node Right() Node Hash() []byte // SafeHash returns byte slice that's safe to retain SafeHash() []byte // PersistedNode clone a new node, MemNode modify in place Mutate(version, cowVersion uint32) *MemNode // Get query the value for a key, it's put into interface because a specialized implementation is more efficient. Get(key []byte) ([]byte, uint32) GetByIndex(uint32) ([]byte, []byte) }
Node interface encapsulate the interface of both PersistedNode and MemNode.
type NodeLayout ¶ added in v0.0.23
type NodeLayout struct {
// contains filtered or unexported fields
}
see comment of `PersistedNode`
func (NodeLayout) Hash ¶ added in v0.0.23
func (node NodeLayout) Hash() []byte
func (NodeLayout) Height ¶ added in v0.0.23
func (node NodeLayout) Height() uint8
func (NodeLayout) KeyLeaf ¶ added in v0.0.23
func (node NodeLayout) KeyLeaf() uint32
func (NodeLayout) PreTrees ¶ added in v0.0.23
func (node NodeLayout) PreTrees() uint8
func (NodeLayout) Size ¶ added in v0.0.23
func (node NodeLayout) Size() uint32
func (NodeLayout) Version ¶ added in v0.0.23
func (node NodeLayout) Version() uint32
type Nodes ¶ added in v0.0.23
type Nodes struct {
// contains filtered or unexported fields
}
Nodes is a continuously stored IAVL nodes
func (Nodes) Node ¶ added in v0.0.23
func (nodes Nodes) Node(i uint32) NodeLayout
type Options ¶ added in v0.0.23
type Options struct { Dir string CreateIfMissing bool InitialVersion uint32 ReadOnly bool // the initial stores when initialize the empty instance InitialStores []string // keep how many snapshots SnapshotKeepRecent uint32 // how often to take a snapshot SnapshotInterval uint32 // Buffer size for the asynchronous commit queue, -1 means synchronous commit, // default to 0. AsyncCommitBuffer int // ZeroCopy if true, the get and iterator methods could return a slice pointing to mmaped blob files. ZeroCopy bool // CacheSize defines the cache's max entry size for each memiavl store. CacheSize int // LoadForOverwriting if true rollbacks the state, specifically the OpenDB method will // truncate the versions after the `TargetVersion`, the `TargetVersion` becomes the latest version. // it do nothing if the target version is `0`. LoadForOverwriting bool // Limit the number of concurrent snapshot writers SnapshotWriterLimit int }
func (*Options) FillDefaults ¶ added in v0.0.23
func (opts *Options) FillDefaults()
type PersistedNode ¶ added in v0.0.23
type PersistedNode struct {
// contains filtered or unexported fields
}
PersistedNode is backed by serialized byte array, usually mmap-ed from disk file. Encoding format (all integers are encoded in little endian):
Branch node: - height : 1 - preTrees : 1 - _padding : 2 - version : 4 - size : 4 - key node : 4 // node index of the smallest leaf in right branch - hash : 32 Leaf node: - version : 4 - key len : 4 - key offset : 8 - hash : 32
func (PersistedNode) Get ¶ added in v0.0.23
func (node PersistedNode) Get(key []byte) ([]byte, uint32)
func (PersistedNode) GetByIndex ¶ added in v0.0.23
func (node PersistedNode) GetByIndex(leafIndex uint32) ([]byte, []byte)
func (PersistedNode) Hash ¶ added in v0.0.23
func (node PersistedNode) Hash() []byte
func (PersistedNode) Height ¶ added in v0.0.23
func (node PersistedNode) Height() uint8
func (PersistedNode) IsLeaf ¶ added in v0.0.23
func (node PersistedNode) IsLeaf() bool
func (PersistedNode) Key ¶ added in v0.0.23
func (node PersistedNode) Key() []byte
func (PersistedNode) Left ¶ added in v0.0.23
func (node PersistedNode) Left() Node
Left result is not defined for leaf nodes.
func (PersistedNode) Mutate ¶ added in v0.0.23
func (node PersistedNode) Mutate(version, _ uint32) *MemNode
func (PersistedNode) Right ¶ added in v0.0.23
func (node PersistedNode) Right() Node
Right result is not defined for leaf nodes.
func (PersistedNode) SafeHash ¶ added in v0.0.23
func (node PersistedNode) SafeHash() []byte
func (PersistedNode) Size ¶ added in v0.0.23
func (node PersistedNode) Size() int64
func (PersistedNode) Value ¶ added in v0.0.23
func (node PersistedNode) Value() []byte
Value returns nil for non-leaf node.
func (PersistedNode) Version ¶ added in v0.0.23
func (node PersistedNode) Version() uint32
type Snapshot ¶ added in v0.0.23
type Snapshot struct {
// contains filtered or unexported fields
}
Snapshot manage the lifecycle of mmap-ed files for the snapshot, it must out live the objects that derived from it.
func NewEmptySnapshot ¶ added in v0.0.23
func OpenSnapshot ¶ added in v0.0.23
OpenSnapshot parse the version number and the root node index from metadata file, and mmap the other files.
func (*Snapshot) Close ¶ added in v0.0.23
Close closes the file and mmap handles, clears the buffers.
func (*Snapshot) Export ¶ added in v0.0.23
Export exports the nodes from snapshot file sequentially, more efficient than a post-order traversal.
func (*Snapshot) KeyValue ¶ added in v0.0.23
KeyValue returns a zero-copy slice of key/value pair by offset
func (*Snapshot) Leaf ¶ added in v0.0.23
func (snapshot *Snapshot) Leaf(index uint32) PersistedNode
Leaf returns the leaf node by index
func (*Snapshot) LeafKeyValue ¶ added in v0.0.23
func (*Snapshot) Node ¶ added in v0.0.23
func (snapshot *Snapshot) Node(index uint32) PersistedNode
Node returns the branch node by index
func (*Snapshot) RootNode ¶ added in v0.0.23
func (snapshot *Snapshot) RootNode() PersistedNode
RootNode returns the root node
type Tree ¶ added in v0.0.23
type Tree struct {
// contains filtered or unexported fields
}
verify change sets by replay them to rebuild iavl tree and verify the root hashes
func NewEmptyTree ¶ added in v0.0.23
NewEmptyTree creates an empty tree at an arbitrary version.
func NewFromSnapshot ¶ added in v0.0.23
NewFromSnapshot mmap the blob files and create the root node.
func NewWithInitialVersion ¶ added in v0.0.23
NewWithInitialVersion creates an empty tree with initial-version, it happens when a new store created at the middle of the chain.
func (*Tree) ApplyChangeSet ¶ added in v0.0.23
ApplyChangeSet apply the change set of a whole version, and update hashes.
func (*Tree) Copy ¶ added in v0.0.23
Copy returns a snapshot of the tree which won't be modified by further modifications on the main tree, the returned new tree can be accessed concurrently with the main tree.
func (*Tree) Export ¶ added in v0.0.23
Export returns a snapshot of the tree which won't be corrupted by further modifications on the main tree.
func (*Tree) GetMembershipProof ¶ added in v0.0.23
func (t *Tree) GetMembershipProof(key []byte) (*ics23.CommitmentProof, error)
GetMembershipProof will produce a CommitmentProof that the given key (and queries value) exists in the iavl tree. If the key doesn't exist in the tree, this will return an error.
func (*Tree) GetNonMembershipProof ¶ added in v0.0.23
func (t *Tree) GetNonMembershipProof(key []byte) (*ics23.CommitmentProof, error)
GetNonMembershipProof will produce a CommitmentProof that the given key doesn't exist in the iavl tree. If the key exists in the tree, this will return an error.
func (*Tree) GetProof ¶ added in v0.0.23
func (t *Tree) GetProof(key []byte) *ics23.CommitmentProof
GetProof takes a key for creating existence or absence proof and returns the appropriate merkle.Proof. Since this must be called after querying for the value, this function should never error Thus, it will panic on error rather than returning it
func (*Tree) GetWithIndex ¶ added in v0.0.23
func (*Tree) ReplaceWith ¶ added in v0.0.29
ReplaceWith is used during reload to replace the current tree with the newly loaded snapshot
func (*Tree) RootHash ¶ added in v0.0.23
RootHash updates the hashes and return the current root hash, it clones the persisted node's bytes, so the returned bytes is safe to retain.
func (*Tree) SaveVersion ¶ added in v0.0.23
SaveVersion increases the version number and optionally updates the hashes
func (*Tree) ScanPostOrder ¶ added in v0.0.23
ScanPostOrder scans the tree in post-order, and call the callback function on each node. If the callback function returns false, the scan will be stopped.
func (*Tree) SetInitialVersion ¶ added in v0.0.23
func (*Tree) SetZeroCopy ¶ added in v0.0.23
func (*Tree) VerifyMembership ¶ added in v0.0.23
func (t *Tree) VerifyMembership(proof *ics23.CommitmentProof, key []byte) bool
VerifyMembership returns true iff proof is an ExistenceProof for the given key.
func (*Tree) VerifyNonMembership ¶ added in v0.0.23
func (t *Tree) VerifyNonMembership(proof *ics23.CommitmentProof, key []byte) bool
VerifyNonMembership returns true iff proof is a NonExistenceProof for the given key.
type TreeImporter ¶ added in v0.0.23
type TreeImporter struct {
// contains filtered or unexported fields
}
TreeImporter import a single memiavl tree from state-sync snapshot
func NewTreeImporter ¶ added in v0.0.23
func NewTreeImporter(dir string, version int64) *TreeImporter
func (*TreeImporter) Add ¶ added in v0.0.23
func (ai *TreeImporter) Add(node *types.SnapshotNode)
func (*TreeImporter) Close ¶ added in v0.0.23
func (ai *TreeImporter) Close() error