Documentation ¶
Index ¶
- Constants
- func LoadStore(db dbm.DB, logger log.Logger, key types.StoreKey, id types.CommitID, ...) (types.CommitKVStore, error)
- func LoadStoreWithInitialVersion(db dbm.DB, logger log.Logger, key types.StoreKey, id types.CommitID, ...) (types.CommitKVStore, error)
- type Store
- func (st *Store) CacheWrap() types.CacheWrap
- func (st *Store) CacheWrapWithTrace(w io.Writer, tc types.TraceContext) types.CacheWrap
- func (st *Store) Commit() types.CommitID
- func (st *Store) Delete(key []byte)
- func (st *Store) DeleteVersionsTo(version int64) error
- func (st *Store) Export(version int64) (*iavl.Exporter, error)
- func (st *Store) Get(key []byte) []byte
- func (st *Store) GetAllVersions() []int
- func (st *Store) GetImmutable(version int64) (*Store, error)
- func (st *Store) GetPruning() pruningtypes.PruningOptions
- func (st *Store) GetStoreType() types.StoreType
- func (st *Store) Has(key []byte) (exists bool)
- func (st *Store) Import(version int64) (*iavl.Importer, error)
- func (st *Store) Iterator(start, end []byte) types.Iterator
- func (st *Store) LastCommitID() types.CommitID
- func (st *Store) LoadVersionForOverwriting(targetVersion int64) error
- func (st *Store) Query(req *types.RequestQuery) (res *types.ResponseQuery, err error)
- func (st *Store) ReverseIterator(start, end []byte) types.Iterator
- func (st *Store) Set(key, value []byte)
- func (st *Store) SetInitialVersion(version int64)
- func (st *Store) SetPruning(_ pruningtypes.PruningOptions)
- func (st *Store) TraverseStateChanges(startVersion, endVersion int64, ...) error
- func (st *Store) VersionExists(version int64) bool
- func (st *Store) WorkingHash() []byte
- type Tree
Constants ¶
const (
DefaultIAVLCacheSize = 500000
)
Variables ¶
This section is empty.
Functions ¶
func LoadStore ¶
func LoadStore(db dbm.DB, logger log.Logger, key types.StoreKey, id types.CommitID, cacheSize int, disableFastNode bool, metrics metrics.StoreMetrics) (types.CommitKVStore, error)
LoadStore returns an IAVL Store as a CommitKVStore. Internally, it will load the store's version (id) from the provided DB. An error is returned if the version fails to load, or if called with a positive version on an empty tree.
func LoadStoreWithInitialVersion ¶
func LoadStoreWithInitialVersion(db dbm.DB, logger log.Logger, key types.StoreKey, id types.CommitID, initialVersion uint64, cacheSize int, disableFastNode bool, metrics metrics.StoreMetrics) (types.CommitKVStore, error)
LoadStoreWithInitialVersion returns an IAVL Store as a CommitKVStore setting its initialVersion to the one given. Internally, it will load the store's version (id) from the provided DB. An error is returned if the version fails to load, or if called with a positive version on an empty tree.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store Implements types.KVStore and CommitKVStore.
func UnsafeNewStore ¶
func UnsafeNewStore(tree *iavl.MutableTree) *Store
UnsafeNewStore returns a reference to a new IAVL Store with a given mutable IAVL tree reference. It should only be used for testing purposes.
CONTRACT: The IAVL tree should be fully loaded. CONTRACT: PruningOptions passed in as argument must be the same as pruning options passed into iavl.MutableTree
func (*Store) CacheWrapWithTrace ¶
CacheWrapWithTrace implements the Store interface.
func (*Store) Commit ¶
Commit commits the current store state and returns a CommitID with the new version and hash.
func (*Store) DeleteVersionsTo ¶
DeleteVersionsTo deletes versions upto the given version from the MutableTree. An error is returned if any single version is invalid or the delete fails. All writes happen in a single batch with a single commit.
func (*Store) Export ¶
Exports the IAVL store at the given version, returning an iavl.Exporter for the tree.
func (*Store) GetAllVersions ¶
GetAllVersions returns all versions in the iavl tree
func (*Store) GetImmutable ¶
GetImmutable returns a reference to a new store backed by an immutable IAVL tree at a specific version (height) without any pruning options. This should be used for querying and iteration only. If the version does not exist or has been pruned, an empty immutable IAVL tree will be used. Any mutable operations executed will result in a panic.
func (*Store) GetPruning ¶
func (st *Store) GetPruning() pruningtypes.PruningOptions
SetPruning panics as pruning options should be provided at initialization since IAVl accepts pruning options directly.
func (*Store) Import ¶
Import imports an IAVL tree at the given version, returning an iavl.Importer for importing.
func (*Store) LastCommitID ¶
LastCommitID implements Committer.
func (*Store) LoadVersionForOverwriting ¶
LoadVersionForOverwriting attempts to load a tree at a previously committed version. Any versions greater than targetVersion will be deleted.
func (*Store) Query ¶
func (st *Store) Query(req *types.RequestQuery) (res *types.ResponseQuery, err error)
Query implements ABCI interface, allows queries
by default we will return from (latest height -1), as we will have merkle proofs immediately (header height = data height + 1) If latest-1 is not present, use latest (which must be present) if you care to have the latest data to see a tx results, you must explicitly set the height you want to see
func (*Store) ReverseIterator ¶
Implements types.KVStore.
func (*Store) SetInitialVersion ¶
SetInitialVersion sets the initial version of the IAVL tree. It is used when starting a new chain at an arbitrary height.
func (*Store) SetPruning ¶
func (st *Store) SetPruning(_ pruningtypes.PruningOptions)
SetPruning panics as pruning options should be provided at initialization since IAVl accepts pruning options directly.
func (*Store) TraverseStateChanges ¶
func (st *Store) TraverseStateChanges(startVersion, endVersion int64, fn func(version int64, changeSet *iavl.ChangeSet) error) error
TraverseStateChanges traverses the state changes between two versions and calls the given function.
func (*Store) VersionExists ¶
VersionExists returns whether or not a given version is stored.
func (*Store) WorkingHash ¶
WorkingHash returns the hash of the current working tree.
type Tree ¶
type Tree interface { Has(key []byte) (bool, error) Get(key []byte) ([]byte, error) Set(key, value []byte) (bool, error) Remove(key []byte) ([]byte, bool, error) SaveVersion() ([]byte, int64, error) Version() int64 Hash() []byte WorkingHash() []byte VersionExists(version int64) bool DeleteVersionsTo(version int64) error GetVersioned(key []byte, version int64) ([]byte, error) GetImmutable(version int64) (*iavl.ImmutableTree, error) SetInitialVersion(version uint64) Iterator(start, end []byte, ascending bool) (idb.Iterator, error) AvailableVersions() []int LoadVersionForOverwriting(targetVersion int64) error TraverseStateChanges(startVersion, endVersion int64, fn func(version int64, changeSet *iavl.ChangeSet) error) error }
Tree defines an interface that both mutable and immutable IAVL trees must implement. For mutable IAVL trees, the interface is directly implemented by an iavl.MutableTree. For an immutable IAVL tree, a wrapper must be made.