Documentation ¶
Index ¶
- Constants
- Variables
- func EncodeBytes(w io.Writer, bz []byte) error
- func HashNode(node Node) []byte
- func Import(dir string, height uint64, format uint32, protoReader protoio.Reader) (snapshottypes.SnapshotItem, error)
- func Mmap(f *os.File) ([]byte, *[mmap.MaxMapSize]byte, error)
- func NewIterator(start, end []byte, ascending bool, root Node, zeroCopy bool) dbm.Iterator
- func VerifyHash(node Node) bool
- func WriteFileSync(name string, data []byte) error
- type DB
- func (db *DB) ApplyChangeSet(changeSets []*NamedChangeSet, updateCommitInfo bool) ([]byte, int64, error)
- func (db *DB) ApplyUpgrades(upgrades []*TreeNameUpgrade) error
- func (db *DB) Close() error
- func (db *DB) Commit(changeSets []*NamedChangeSet) ([]byte, int64, error)
- func (db *DB) Copy() *DB
- func (db *DB) Hash() []byte
- func (db *DB) LastCommitInfo() *storetypes.CommitInfo
- func (db *DB) Reload() error
- func (db *DB) RewriteSnapshot() error
- func (db *DB) RewriteSnapshotBackground() error
- func (db *DB) SetInitialVersion(initialVersion int64) error
- func (db *DB) Snapshot(height uint64, protoWriter protoio.Writer) error
- func (db *DB) TreeByName(name string) *Tree
- func (db *DB) UpdateCommitInfo() []byte
- func (db *DB) Version() int64
- func (db *DB) WriteSnapshot(dir string) error
- type Exporter
- 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) Size() int64
- func (node *MemNode) Value() []byte
- func (node *MemNode) Version() uint32
- type MmapFile
- type MultiTree
- func (t *MultiTree) ApplyChangeSet(changeSets []*NamedChangeSet, updateCommitInfo bool) ([]byte, int64, error)
- func (t *MultiTree) ApplyUpgrades(upgrades []*TreeNameUpgrade) error
- func (t *MultiTree) CatchupWAL(wal *wal.Log, endVersion int64) error
- func (t *MultiTree) Close() error
- func (t *MultiTree) Copy() *MultiTree
- func (t *MultiTree) Hash() []byte
- func (t *MultiTree) LastCommitInfo() *storetypes.CommitInfo
- func (t *MultiTree) SetInitialVersion(initialVersion int64) error
- func (t *MultiTree) SetZeroCopy(zeroCopy bool)
- func (t *MultiTree) TreeByName(name string) *Tree
- func (t *MultiTree) UpdateCommitInfo() []byte
- func (t *MultiTree) Version() int64
- func (t *MultiTree) WriteSnapshot(dir string) error
- type MultiTreeMetadata
- func (*MultiTreeMetadata) Descriptor() ([]byte, []int)
- func (m *MultiTreeMetadata) GetCommitInfo() *types.CommitInfo
- func (m *MultiTreeMetadata) GetInitialVersion() int64
- func (m *MultiTreeMetadata) Marshal() (dAtA []byte, err error)
- func (m *MultiTreeMetadata) MarshalTo(dAtA []byte) (int, error)
- func (m *MultiTreeMetadata) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*MultiTreeMetadata) ProtoMessage()
- func (m *MultiTreeMetadata) Reset()
- func (m *MultiTreeMetadata) Size() (n int)
- func (m *MultiTreeMetadata) String() string
- func (m *MultiTreeMetadata) Unmarshal(dAtA []byte) error
- func (m *MultiTreeMetadata) XXX_DiscardUnknown()
- func (m *MultiTreeMetadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *MultiTreeMetadata) XXX_Merge(src proto.Message)
- func (m *MultiTreeMetadata) XXX_Size() int
- func (m *MultiTreeMetadata) XXX_Unmarshal(b []byte) error
- type NamedChangeSet
- func (*NamedChangeSet) Descriptor() ([]byte, []int)
- func (m *NamedChangeSet) GetChangeset() proto1.ChangeSet
- func (m *NamedChangeSet) GetName() string
- func (m *NamedChangeSet) Marshal() (dAtA []byte, err error)
- func (m *NamedChangeSet) MarshalTo(dAtA []byte) (int, error)
- func (m *NamedChangeSet) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*NamedChangeSet) ProtoMessage()
- func (m *NamedChangeSet) Reset()
- func (m *NamedChangeSet) Size() (n int)
- func (m *NamedChangeSet) String() string
- func (m *NamedChangeSet) Unmarshal(dAtA []byte) error
- func (m *NamedChangeSet) XXX_DiscardUnknown()
- func (m *NamedChangeSet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *NamedChangeSet) XXX_Merge(src proto.Message)
- func (m *NamedChangeSet) XXX_Size() int
- func (m *NamedChangeSet) XXX_Unmarshal(b []byte) error
- 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) 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) Get(key []byte) []byte
- 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, updateHash bool) ([]byte, int64, error)
- func (t *Tree) Close() error
- func (t *Tree) Copy() *Tree
- 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) 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) RootHash() []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(snapshotDir string, writeHashIndex bool) error
- type TreeImporter
- type TreeNameUpgrade
- func (*TreeNameUpgrade) Descriptor() ([]byte, []int)
- func (m *TreeNameUpgrade) GetDelete() bool
- func (m *TreeNameUpgrade) GetName() string
- func (m *TreeNameUpgrade) GetRenameFrom() string
- func (m *TreeNameUpgrade) Marshal() (dAtA []byte, err error)
- func (m *TreeNameUpgrade) MarshalTo(dAtA []byte) (int, error)
- func (m *TreeNameUpgrade) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*TreeNameUpgrade) ProtoMessage()
- func (m *TreeNameUpgrade) Reset()
- func (m *TreeNameUpgrade) Size() (n int)
- func (m *TreeNameUpgrade) String() string
- func (m *TreeNameUpgrade) Unmarshal(dAtA []byte) error
- func (m *TreeNameUpgrade) XXX_DiscardUnknown()
- func (m *TreeNameUpgrade) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *TreeNameUpgrade) XXX_Merge(src proto.Message)
- func (m *TreeNameUpgrade) XXX_Size() int
- func (m *TreeNameUpgrade) XXX_Unmarshal(b []byte) error
- type WALEntry
- func (*WALEntry) Descriptor() ([]byte, []int)
- func (m *WALEntry) GetChangesets() []*NamedChangeSet
- func (m *WALEntry) GetUpgrades() []*TreeNameUpgrade
- func (m *WALEntry) Marshal() (dAtA []byte, err error)
- func (m *WALEntry) MarshalTo(dAtA []byte) (int, error)
- func (m *WALEntry) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*WALEntry) ProtoMessage()
- func (m *WALEntry) Reset()
- func (m *WALEntry) Size() (n int)
- func (m *WALEntry) String() string
- func (m *WALEntry) Unmarshal(dAtA []byte) error
- func (m *WALEntry) XXX_DiscardUnknown()
- func (m *WALEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *WALEntry) XXX_Merge(src proto.Message)
- func (m *WALEntry) XXX_Size() int
- func (m *WALEntry) XXX_Unmarshal(b []byte) error
Constants ¶
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" FileNameKVIndex = "kvs.index" FileNameMetadata = "metadata" )
const MetadataFileName = "__metadata"
const (
SnapshotPrefix = "snapshot-"
)
Variables ¶
Functions ¶
func EncodeBytes ¶
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 Import ¶
func Import( dir string, height uint64, format uint32, protoReader protoio.Reader, ) (snapshottypes.SnapshotItem, error)
Import restore memiavl db from state-sync snapshot stream
func NewIterator ¶
func VerifyHash ¶
VerifyHash compare node's cached hash with computed one
func WriteFileSync ¶
WriteFileSync calls `f.Sync` after before closing the file
Types ¶
type DB ¶
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 > wal ```
func (*DB) ApplyChangeSet ¶
func (db *DB) ApplyChangeSet(changeSets []*NamedChangeSet, updateCommitInfo bool) ([]byte, int64, error)
ApplyChangeSet wraps MultiTree.ApplyChangeSet to add a lock.
func (*DB) ApplyUpgrades ¶
func (db *DB) ApplyUpgrades(upgrades []*TreeNameUpgrade) error
ApplyUpgrades wraps MultiTree.ApplyUpgrades, it also append the upgrades in a temporary field, and include in the WAL entry in next Commit call.
func (*DB) Commit ¶
func (db *DB) Commit(changeSets []*NamedChangeSet) ([]byte, int64, error)
Commit wraps `MultiTree.ApplyChangeSet` to add some db level operations: - manage background snapshot rewriting - write WAL
func (*DB) LastCommitInfo ¶
func (db *DB) LastCommitInfo() *storetypes.CommitInfo
LastCommitInfo returns the last commit info.
func (*DB) RewriteSnapshot ¶
RewriteSnapshot writes the current version of memiavl into a snapshot, and update the `current` symlink.
func (*DB) RewriteSnapshotBackground ¶
RewriteSnapshotBackground rewrite snapshot in a background goroutine, `Commit` will check the complete status, and switch to the new snapshot.
func (*DB) SetInitialVersion ¶
SetInitialVersion wraps `MultiTree.SetInitialVersion`. it do an immediate snapshot rewrite, because we can't use wal log to record this change, because we need it to convert versions to wal index in the first place.
func (*DB) TreeByName ¶
TreeByName wraps MultiTree.TreeByName to add a lock.
func (*DB) UpdateCommitInfo ¶
UpdateCommitInfo wraps MultiTree.UpdateCommitInfo to add a lock.
func (*DB) WriteSnapshot ¶
WriteSnapshot wraps MultiTree.WriteSnapshot to add a lock.
type Exporter ¶
type Exporter struct {
// contains filtered or unexported fields
}
type LeafLayout ¶
type LeafLayout struct {
// contains filtered or unexported fields
}
func (LeafLayout) Hash ¶
func (leaf LeafLayout) Hash() []byte
func (LeafLayout) KeyLength ¶
func (leaf LeafLayout) KeyLength() uint32
func (LeafLayout) KeyOffset ¶
func (leaf LeafLayout) KeyOffset() uint64
func (LeafLayout) Version ¶
func (leaf LeafLayout) Version() uint32
type Leaves ¶
type Leaves struct {
// contains filtered or unexported fields
}
Leaves is a continuously stored IAVL nodes
func (Leaves) Leaf ¶
func (leaves Leaves) Leaf(i uint32) LeafLayout
type MemNode ¶
type MemNode struct {
// contains filtered or unexported fields
}
func (*MemNode) Hash ¶
Computes the hash of the node without computing its descendants. Must be called on nodes which have descendant node hashes already computed.
type MmapFile ¶
type MmapFile struct {
// contains filtered or unexported fields
}
MmapFile manage the resources of a mmap-ed file
type MultiTree ¶
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 NewEmptyMultiTree ¶
func (*MultiTree) ApplyChangeSet ¶
func (t *MultiTree) ApplyChangeSet(changeSets []*NamedChangeSet, updateCommitInfo bool) ([]byte, int64, error)
ApplyChangeSet applies change sets for all trees. if `updateCommitInfo` is `false`, the `lastCommitInfo.StoreInfos` is dirty.
func (*MultiTree) ApplyUpgrades ¶
func (t *MultiTree) ApplyUpgrades(upgrades []*TreeNameUpgrade) error
ApplyUpgrades store name upgrades
func (*MultiTree) CatchupWAL ¶
CatchupWAL replay the new entries in the WAL on the tree to catch-up to the target or latest version.
func (*MultiTree) Copy ¶
Copy returns a snapshot of the tree which won't be corrupted by further modifications on the main tree.
func (*MultiTree) LastCommitInfo ¶
func (t *MultiTree) LastCommitInfo() *storetypes.CommitInfo
func (*MultiTree) SetInitialVersion ¶
func (*MultiTree) SetZeroCopy ¶
func (*MultiTree) TreeByName ¶
TreeByName returns the tree by name, returns nil if not found
func (*MultiTree) UpdateCommitInfo ¶
UpdateCommitInfo update lastCommitInfo based on current status of trees. it's needed if `updateCommitInfo` is set to `false` in `ApplyChangeSet`.
func (*MultiTree) WriteSnapshot ¶
type MultiTreeMetadata ¶
type MultiTreeMetadata struct { CommitInfo *types.CommitInfo `protobuf:"bytes,1,opt,name=commit_info,json=commitInfo,proto3" json:"commit_info,omitempty"` InitialVersion int64 `protobuf:"varint,2,opt,name=initial_version,json=initialVersion,proto3" json:"initial_version,omitempty"` }
MultiTreeMetadata stores the metadata for MultiTree
func (*MultiTreeMetadata) Descriptor ¶
func (*MultiTreeMetadata) Descriptor() ([]byte, []int)
func (*MultiTreeMetadata) GetCommitInfo ¶
func (m *MultiTreeMetadata) GetCommitInfo() *types.CommitInfo
func (*MultiTreeMetadata) GetInitialVersion ¶
func (m *MultiTreeMetadata) GetInitialVersion() int64
func (*MultiTreeMetadata) Marshal ¶
func (m *MultiTreeMetadata) Marshal() (dAtA []byte, err error)
func (*MultiTreeMetadata) MarshalTo ¶
func (m *MultiTreeMetadata) MarshalTo(dAtA []byte) (int, error)
func (*MultiTreeMetadata) MarshalToSizedBuffer ¶
func (m *MultiTreeMetadata) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*MultiTreeMetadata) ProtoMessage ¶
func (*MultiTreeMetadata) ProtoMessage()
func (*MultiTreeMetadata) Reset ¶
func (m *MultiTreeMetadata) Reset()
func (*MultiTreeMetadata) Size ¶
func (m *MultiTreeMetadata) Size() (n int)
func (*MultiTreeMetadata) String ¶
func (m *MultiTreeMetadata) String() string
func (*MultiTreeMetadata) Unmarshal ¶
func (m *MultiTreeMetadata) Unmarshal(dAtA []byte) error
func (*MultiTreeMetadata) XXX_DiscardUnknown ¶
func (m *MultiTreeMetadata) XXX_DiscardUnknown()
func (*MultiTreeMetadata) XXX_Marshal ¶
func (m *MultiTreeMetadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*MultiTreeMetadata) XXX_Merge ¶
func (m *MultiTreeMetadata) XXX_Merge(src proto.Message)
func (*MultiTreeMetadata) XXX_Size ¶
func (m *MultiTreeMetadata) XXX_Size() int
func (*MultiTreeMetadata) XXX_Unmarshal ¶
func (m *MultiTreeMetadata) XXX_Unmarshal(b []byte) error
type NamedChangeSet ¶
type NamedChangeSet struct { Changeset proto1.ChangeSet `protobuf:"bytes,1,opt,name=changeset,proto3" json:"changeset"` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` }
NamedChangeSet combine a tree name with the changeset
func (*NamedChangeSet) Descriptor ¶
func (*NamedChangeSet) Descriptor() ([]byte, []int)
func (*NamedChangeSet) GetChangeset ¶
func (m *NamedChangeSet) GetChangeset() proto1.ChangeSet
func (*NamedChangeSet) GetName ¶
func (m *NamedChangeSet) GetName() string
func (*NamedChangeSet) Marshal ¶
func (m *NamedChangeSet) Marshal() (dAtA []byte, err error)
func (*NamedChangeSet) MarshalToSizedBuffer ¶
func (m *NamedChangeSet) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*NamedChangeSet) ProtoMessage ¶
func (*NamedChangeSet) ProtoMessage()
func (*NamedChangeSet) Reset ¶
func (m *NamedChangeSet) Reset()
func (*NamedChangeSet) Size ¶
func (m *NamedChangeSet) Size() (n int)
func (*NamedChangeSet) String ¶
func (m *NamedChangeSet) String() string
func (*NamedChangeSet) Unmarshal ¶
func (m *NamedChangeSet) Unmarshal(dAtA []byte) error
func (*NamedChangeSet) XXX_DiscardUnknown ¶
func (m *NamedChangeSet) XXX_DiscardUnknown()
func (*NamedChangeSet) XXX_Marshal ¶
func (m *NamedChangeSet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*NamedChangeSet) XXX_Merge ¶
func (m *NamedChangeSet) XXX_Merge(src proto.Message)
func (*NamedChangeSet) XXX_Size ¶
func (m *NamedChangeSet) XXX_Size() int
func (*NamedChangeSet) XXX_Unmarshal ¶
func (m *NamedChangeSet) XXX_Unmarshal(b []byte) error
type Node ¶
type Node interface { Height() uint8 IsLeaf() bool Size() int64 Version() uint32 Key() []byte Value() []byte Left() Node Right() Node Hash() []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 ¶
type NodeLayout struct {
// contains filtered or unexported fields
}
see comment of `PersistedNode`
func (NodeLayout) Hash ¶
func (node NodeLayout) Hash() []byte
func (NodeLayout) Height ¶
func (node NodeLayout) Height() uint8
func (NodeLayout) KeyLeaf ¶
func (node NodeLayout) KeyLeaf() uint32
func (NodeLayout) PreTrees ¶
func (node NodeLayout) PreTrees() uint8
func (NodeLayout) Size ¶
func (node NodeLayout) Size() uint32
func (NodeLayout) Version ¶
func (node NodeLayout) Version() uint32
type Nodes ¶
type Nodes struct {
// contains filtered or unexported fields
}
Nodes is a continuously stored IAVL nodes
func (Nodes) Node ¶
func (nodes Nodes) Node(i uint32) NodeLayout
type Options ¶
type Options struct { CreateIfMissing bool InitialVersion uint32 // the initial stores when initialize the empty instance InitialStores []string SnapshotKeepRecent uint32 // load the target version instead of latest version TargetVersion uint32 // Write WAL asynchronously, it's ok in blockchain case because we can always replay the raw blocks. AsyncWAL bool // ZeroCopy if true, the get and iterator methods could return a slice pointing to mmaped blob files. ZeroCopy bool }
type PersistedNode ¶
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) GetByIndex ¶
func (node PersistedNode) GetByIndex(leafIndex uint32) ([]byte, []byte)
func (PersistedNode) Hash ¶
func (node PersistedNode) Hash() []byte
func (PersistedNode) Height ¶
func (node PersistedNode) Height() uint8
func (PersistedNode) IsLeaf ¶
func (node PersistedNode) IsLeaf() bool
func (PersistedNode) Key ¶
func (node PersistedNode) Key() []byte
func (PersistedNode) Left ¶
func (node PersistedNode) Left() Node
Left result is not defined for leaf nodes.
func (PersistedNode) Mutate ¶
func (node PersistedNode) Mutate(version, _ uint32) *MemNode
func (PersistedNode) Right ¶
func (node PersistedNode) Right() Node
Right result is not defined for leaf nodes.
func (PersistedNode) Size ¶
func (node PersistedNode) Size() int64
func (PersistedNode) Value ¶
func (node PersistedNode) Value() []byte
Value result is not defined for non-leaf node.
func (PersistedNode) Version ¶
func (node PersistedNode) Version() uint32
type Snapshot ¶
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 ¶
func OpenSnapshot ¶
OpenSnapshot parse the version number and the root node index from metadata file, and mmap the other files.
func (*Snapshot) Export ¶
Export exports the nodes in DFS post-order, resemble the API of existing iavl library
func (*Snapshot) Leaf ¶
func (snapshot *Snapshot) Leaf(index uint32) PersistedNode
Leaf returns the leaf node by index
func (*Snapshot) LeafKeyValue ¶
func (*Snapshot) Node ¶
func (snapshot *Snapshot) Node(index uint32) PersistedNode
Node returns the branch node by index
func (*Snapshot) RootNode ¶
func (snapshot *Snapshot) RootNode() PersistedNode
RootNode returns the root node
type Tree ¶
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 ¶
NewEmptyTree creates an empty tree at an arbitrary version.
func NewFromSnapshot ¶
NewFromSnapshot mmap the blob files and create the root node.
func NewWithInitialVersion ¶
New creates a empty tree with initial-version, it happens when a new store created at the middle of the chain.
func (*Tree) ApplyChangeSet ¶
ApplyChangeSet apply the change set of a whole version, and update hashes.
func (*Tree) Copy ¶
Copy returns a snapshot of the tree which won't be corrupted by further modifications on the main tree.
func (*Tree) GetMembershipProof ¶
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 ¶
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) SetInitialVersion ¶
func (*Tree) SetZeroCopy ¶
func (*Tree) VerifyMembership ¶
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 ¶
func (t *Tree) VerifyNonMembership(proof *ics23.CommitmentProof, key []byte) bool
VerifyNonMembership returns true iff proof is a NonExistenceProof for the given key.
type TreeImporter ¶
type TreeImporter struct {
// contains filtered or unexported fields
}
TreeImporter import a single memiavl tree from state-sync snapshot
func NewTreeImporter ¶
func NewTreeImporter(dir string, version int64) *TreeImporter
func (*TreeImporter) Add ¶
func (ai *TreeImporter) Add(node *iavl.ExportNode)
func (*TreeImporter) Close ¶
func (ai *TreeImporter) Close() error
type TreeNameUpgrade ¶
type TreeNameUpgrade struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` RenameFrom string `protobuf:"bytes,2,opt,name=rename_from,json=renameFrom,proto3" json:"rename_from,omitempty"` Delete bool `protobuf:"varint,3,opt,name=delete,proto3" json:"delete,omitempty"` }
TreeNameUpgrade defines upgrade of tree names: - New tree: { name: "tree" } - Delete tree: { name: "tree", delete: true } - Rename tree: { name: "new-tree", rename_from: "old-tree" }
func (*TreeNameUpgrade) Descriptor ¶
func (*TreeNameUpgrade) Descriptor() ([]byte, []int)
func (*TreeNameUpgrade) GetDelete ¶
func (m *TreeNameUpgrade) GetDelete() bool
func (*TreeNameUpgrade) GetName ¶
func (m *TreeNameUpgrade) GetName() string
func (*TreeNameUpgrade) GetRenameFrom ¶
func (m *TreeNameUpgrade) GetRenameFrom() string
func (*TreeNameUpgrade) Marshal ¶
func (m *TreeNameUpgrade) Marshal() (dAtA []byte, err error)
func (*TreeNameUpgrade) MarshalToSizedBuffer ¶
func (m *TreeNameUpgrade) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*TreeNameUpgrade) ProtoMessage ¶
func (*TreeNameUpgrade) ProtoMessage()
func (*TreeNameUpgrade) Reset ¶
func (m *TreeNameUpgrade) Reset()
func (*TreeNameUpgrade) Size ¶
func (m *TreeNameUpgrade) Size() (n int)
func (*TreeNameUpgrade) String ¶
func (m *TreeNameUpgrade) String() string
func (*TreeNameUpgrade) Unmarshal ¶
func (m *TreeNameUpgrade) Unmarshal(dAtA []byte) error
func (*TreeNameUpgrade) XXX_DiscardUnknown ¶
func (m *TreeNameUpgrade) XXX_DiscardUnknown()
func (*TreeNameUpgrade) XXX_Marshal ¶
func (m *TreeNameUpgrade) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*TreeNameUpgrade) XXX_Merge ¶
func (m *TreeNameUpgrade) XXX_Merge(src proto.Message)
func (*TreeNameUpgrade) XXX_Size ¶
func (m *TreeNameUpgrade) XXX_Size() int
func (*TreeNameUpgrade) XXX_Unmarshal ¶
func (m *TreeNameUpgrade) XXX_Unmarshal(b []byte) error
type WALEntry ¶
type WALEntry struct { Changesets []*NamedChangeSet `protobuf:"bytes,1,rep,name=changesets,proto3" json:"changesets,omitempty"` Upgrades []*TreeNameUpgrade `protobuf:"bytes,2,rep,name=upgrades,proto3" json:"upgrades,omitempty"` }
WALEntry is a single Write-Ahead-Log entry
func (*WALEntry) Descriptor ¶
func (*WALEntry) GetChangesets ¶
func (m *WALEntry) GetChangesets() []*NamedChangeSet
func (*WALEntry) GetUpgrades ¶
func (m *WALEntry) GetUpgrades() []*TreeNameUpgrade
func (*WALEntry) MarshalToSizedBuffer ¶
func (*WALEntry) ProtoMessage ¶
func (*WALEntry) ProtoMessage()
func (*WALEntry) XXX_DiscardUnknown ¶
func (m *WALEntry) XXX_DiscardUnknown()