iavl

package
v0.46.0-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 20, 2022 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultIAVLCacheSize = 1024 * 1024 * 100
)
View Source
const (
	// MetricsSubsystem is a subsystem shared by all metrics exposed by this
	// package.
	MetricsSubsystem = "iavl_cache"
)

Variables

This section is empty.

Functions

func LoadStore

func LoadStore(db tmdb.DB, cacheManager types.CacheManager, id types.CommitID, lazyLoading bool, cacheSize int) (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 tmdb.DB, cacheManager types.CacheManager, id types.CommitID, lazyLoading bool, initialVersion uint64, cacheSize int) (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.

func NewCacheManagerNoCache added in v0.43.0

func NewCacheManagerNoCache() types.CacheManager

func NewCacheManagerSingleton added in v0.43.0

func NewCacheManagerSingleton(cacheSize int, provider MetricsProvider) types.CacheManager

func NewFastCache added in v0.45.0

func NewFastCache(cacheSize int) types.Cache

func NewFreeCache added in v0.45.0

func NewFreeCache(cacheSize int) types.Cache

func NewRistrettoCache added in v0.45.0

func NewRistrettoCache(cacheSize int) types.Cache

func NopMetricsProvider added in v0.43.0

func NopMetricsProvider() func() *Metrics

NopMetricsProvider returns NopMetrics for each store

func PausePrefetcher added in v0.45.0

func PausePrefetcher()

func PrometheusMetricsProvider added in v0.43.0

func PrometheusMetricsProvider(namespace string, labelsAndValues ...string) func() *Metrics

PrometheusMetricsProvider returns PrometheusMetrics for each store

func ResumePrefetcher added in v0.45.0

func ResumePrefetcher()

func StartPrefetch added in v0.45.0

func StartPrefetch()

func StopPrefetch added in v0.45.0

func StopPrefetch()

Types

type CacheManagerNoCache added in v0.43.0

type CacheManagerNoCache struct{}

func (*CacheManagerNoCache) GetCache added in v0.43.0

func (cmn *CacheManagerNoCache) GetCache() types.Cache

type CacheManagerSingleton added in v0.43.0

type CacheManagerSingleton struct {
	// contains filtered or unexported fields
}

func (*CacheManagerSingleton) GetCache added in v0.43.0

func (cms *CacheManagerSingleton) GetCache() types.Cache

type Metrics added in v0.43.0

type Metrics struct {
	IAVLCacheHits      metrics.Gauge
	IAVLCacheMisses    metrics.Gauge
	IAVLCacheEntries   metrics.Gauge
	IAVLCacheBytes     metrics.Gauge
	IAVLCachePeakBytes metrics.Gauge
}

Metrics contains metrics exposed by this package.

func NopMetrics added in v0.43.0

func NopMetrics() *Metrics

NopMetrics returns no-op Metrics.

func PrometheusMetrics added in v0.43.0

func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics

PrometheusMetrics returns Metrics build using Prometheus client library. Optionally, labels can be provided along with their values ("foo", "fooValue").

type MetricsProvider added in v0.43.0

type MetricsProvider func() *Metrics

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) CacheWrap

func (st *Store) CacheWrap() types.CacheWrap

Implements Store.

func (*Store) CacheWrapWithListeners added in v0.46.0

func (st *Store) CacheWrapWithListeners(storeKey types.StoreKey, listeners []types.WriteListener) types.CacheWrap

CacheWrapWithListeners implements the CacheWrapper interface.

func (*Store) CacheWrapWithTrace

func (st *Store) CacheWrapWithTrace(w io.Writer, tc types.TraceContext) types.CacheWrap

CacheWrapWithTrace implements the Store interface.

func (*Store) Commit

func (st *Store) Commit() types.CommitID

Commit commits the current store state and returns a CommitID with the new version and hash.

func (*Store) Delete

func (st *Store) Delete(key []byte)

Implements types.KVStore.

func (*Store) DeleteVersions

func (st *Store) DeleteVersions(versions ...int64) error

DeleteVersions deletes a series of versions 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 added in v0.43.0

func (st *Store) Export(version int64) (*iavl.Exporter, error)

Exports the IAVL store at the given version, returning an iavl.Exporter for the tree.

func (*Store) Get

func (st *Store) Get(key []byte) []byte

Implements types.KVStore.

func (*Store) GetImmutable

func (st *Store) GetImmutable(version int64) (*Store, error)

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 added in v0.43.0

func (st *Store) GetPruning() types.PruningOptions

SetPruning panics as pruning options should be provided at initialization since IAVl accepts pruning options directly.

func (*Store) GetStoreType

func (st *Store) GetStoreType() types.StoreType

Implements Store.

func (*Store) Has

func (st *Store) Has(key []byte) (exists bool)

Implements types.KVStore.

func (*Store) Import added in v0.43.0

func (st *Store) Import(version int64) (*iavl.Importer, error)

Import imports an IAVL tree at the given version, returning an iavl.Importer for importing.

func (*Store) Iterator

func (st *Store) Iterator(start, end []byte) types.Iterator

Implements types.KVStore.

func (*Store) LastCommitID

func (st *Store) LastCommitID() types.CommitID

LastCommitID implements Committer.

func (*Store) Prefetch added in v0.45.0

func (st *Store) Prefetch(key []byte, forSet bool) (hits, misses int, value []byte)

Implements type.KVStore.

func (*Store) Query

func (st *Store) Query(req abci.RequestQuery) (res abci.ResponseQuery)

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

func (st *Store) ReverseIterator(start, end []byte) types.Iterator

Implements types.KVStore.

func (*Store) Set

func (st *Store) Set(key, value []byte)

Implements types.KVStore.

func (*Store) SetInitialVersion added in v0.43.0

func (st *Store) SetInitialVersion(version int64)

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(_ types.PruningOptions)

SetPruning panics as pruning options should be provided at initialization since IAVl accepts pruning options directly.

func (*Store) VersionExists

func (st *Store) VersionExists(version int64) bool

VersionExists returns whether or not a given version is stored.

type Tree

type Tree interface {
	Has(key []byte) bool
	Get(key []byte) (index int64, value []byte)
	Set(key, value []byte) bool
	Remove(key []byte) ([]byte, bool)
	SaveVersion() ([]byte, int64, error)
	DeleteVersion(version int64) error
	DeleteVersions(versions ...int64) error
	Version() int64
	Hash() []byte
	VersionExists(version int64) bool
	GetVersioned(key []byte, version int64) (int64, []byte)
	GetVersionedWithProof(key []byte, version int64) ([]byte, *iavl.RangeProof, error)
	GetImmutable(version int64) (*iavl.ImmutableTree, error)
	SetInitialVersion(version uint64)
	Prefetch(key []byte, forSet bool) (hits, misses int, value []byte)
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL