root

package
v2.0.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 20 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateRootStore

func CreateRootStore(opts *FactoryOptions) (store.RootStore, error)

CreateRootStore is a convenience function to create a root store based on the provided FactoryOptions. Strictly speaking app developers can create the root store directly by calling root.New, so this function is not necessary, but demonstrates the required steps and configuration to create a root store.

func New

func New(
	dbCloser io.Closer,
	logger corelog.Logger,
	sc store.Committer,
	pm *pruning.Manager,
	mm *migration.Manager,
	m metrics.StoreMetrics,
) (store.RootStore, error)

New creates a new root Store instance.

NOTE: The migration manager is optional and can be nil if no migration is required.

Types

type Builder

type Builder interface {
	// Build creates a new store/v2 RootStore from the given Config.
	Build(log.Logger, *Config) (store.RootStore, error)
	// RegisterKey registers a store key (namespace) to be used when building the RootStore.
	RegisterKey(string)
	// Get returns the Store.  Build should be called before calling Get or the result will be nil.
	Get() store.RootStore
}

Builder is the interface for a store/v2 RootStore builder. RootStores built by the Cosmos SDK typically involve a 2 phase initialization:

  1. Namespace registration
  2. Configuration and loading

The Builder interface is used to facilitate this pattern. Namespaces (store keys) are registered by calling RegisterKey before Build is called. Build is then called with a Config object and a RootStore is returned. Calls to Get may return the `RootStore` if Build was successful, but that's left up to the implementation.

func NewBuilder

func NewBuilder() Builder

type Config

type Config struct {
	Home         string  `toml:"-"` // this field is omitted in the TOML file
	AppDBBackend string  `mapstructure:"app-db-backend" toml:"app-db-backend" comment:"The type of database for application and snapshots databases."`
	Options      Options `mapstructure:"options" toml:"options"`
}

func DefaultConfig

func DefaultConfig() *Config

type FactoryOptions

type FactoryOptions struct {
	Logger    log.Logger
	RootDir   string
	Options   Options
	StoreKeys []string
	SCRawDB   corestore.KVStoreWithBatch
}

FactoryOptions are the options for creating a root store.

type Options

type Options struct {
	SCType          SCType               `` /* 126-byte string literal not displayed */
	SCPruningOption *store.PruningOption `mapstructure:"sc-pruning-option" toml:"sc-pruning-option" comment:"Pruning options for state commitment"`
	IavlConfig      *iavl.Config         `mapstructure:"iavl-config" toml:"iavl-config"`
}

Options are the options for creating a root store.

func DefaultStoreOptions

func DefaultStoreOptions() Options

DefaultStoreOptions returns the default options for creating a root store.

type Reader

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

Reader represents a read-only adapter for accessing data from the root store.

func NewReader

func NewReader(v uint64, vr store.VersionedReader, actor []byte) *Reader

func (*Reader) Get

func (roa *Reader) Get(key []byte) ([]byte, error)

func (*Reader) Has

func (roa *Reader) Has(key []byte) (bool, error)

func (*Reader) Iterator

func (roa *Reader) Iterator(start, end []byte) (corestore.Iterator, error)

func (*Reader) ReverseIterator

func (roa *Reader) ReverseIterator(start, end []byte) (corestore.Iterator, error)

type ReaderMap

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

ReaderMap defines an adapter around a RootStore that only exposes read-only operations. This is useful for exposing a read-only view of the RootStore at a specific version in history, which could also be the latest state.

func NewReaderMap

func NewReaderMap(v uint64, vr store.VersionedReader) *ReaderMap

func (*ReaderMap) GetReader

func (rm *ReaderMap) GetReader(actor []byte) (corestore.Reader, error)

type SCType

type SCType string
const (
	SCTypeIavl   SCType = "iavl"
	SCTypeIavlV2 SCType = "iavl-v2"
)

type Store

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

Store defines the SDK's default RootStore implementation. It contains a single State Storage (SS) backend and a single State Commitment (SC) backend. The SC backend may or may not support multiple store keys and is implementation dependent.

func (*Store) Close

func (s *Store) Close() (err error)

Close closes the store and resets all internal fields. Note, Close() is NOT idempotent and should only be called once.

func (*Store) Commit

func (s *Store) Commit(cs *corestore.Changeset) ([]byte, error)

Commit commits all state changes to the underlying SS and SC backends. It writes a batch of the changeset to the SC tree, and retrieves the CommitInfo from the SC tree. Finally, it commits the SC tree and returns the hash of the CommitInfo.

func (*Store) GetLatestVersion

func (s *Store) GetLatestVersion() (uint64, error)

GetLatestVersion returns the latest version based on the latest internal CommitInfo. An error is returned if the latest CommitInfo or version cannot be retrieved.

func (*Store) GetStateCommitment

func (s *Store) GetStateCommitment() store.Committer

func (*Store) LastCommitID

func (s *Store) LastCommitID() (proof.CommitID, error)

LastCommitID returns a CommitID based off of the latest internal CommitInfo. If an internal CommitInfo is not set, a new one will be returned with only the latest version set, which is based off of the SC view.

func (*Store) LoadLatestVersion

func (s *Store) LoadLatestVersion() error

func (*Store) LoadVersion

func (s *Store) LoadVersion(version uint64) error

func (*Store) LoadVersionAndUpgrade

func (s *Store) LoadVersionAndUpgrade(version uint64, upgrades *corestore.StoreUpgrades) error

LoadVersionAndUpgrade implements the UpgradeableStore interface.

NOTE: It cannot be called while the store is migrating.

func (*Store) LoadVersionForOverwriting

func (s *Store) LoadVersionForOverwriting(version uint64) error

func (*Store) Prune

func (s *Store) Prune(version uint64) error

func (*Store) Query

func (s *Store) Query(storeKey []byte, version uint64, key []byte, prove bool) (store.QueryResult, error)

func (*Store) SetInitialVersion

func (s *Store) SetInitialVersion(v uint64) error

func (*Store) SetMetrics

func (s *Store) SetMetrics(m metrics.Metrics)

func (*Store) StateAt

func (s *Store) StateAt(v uint64) (corestore.ReaderMap, error)

StateAt returns a read-only view of the state at a given version.

func (*Store) StateLatest

func (s *Store) StateLatest() (uint64, corestore.ReaderMap, error)

Jump to

Keyboard shortcuts

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