Documentation ¶
Index ¶
- func CreateRootStore(opts *FactoryOptions) (store.RootStore, error)
- func New(dbCloser io.Closer, logger corelog.Logger, sc store.Committer, ...) (store.RootStore, error)
- type Builder
- type Config
- type FactoryOptions
- type Options
- type Reader
- type ReaderMap
- type SCType
- type Store
- func (s *Store) Close() (err error)
- func (s *Store) Commit(cs *corestore.Changeset) ([]byte, error)
- func (s *Store) GetLatestVersion() (uint64, error)
- func (s *Store) GetStateCommitment() store.Committer
- func (s *Store) LastCommitID() (proof.CommitID, error)
- func (s *Store) LoadLatestVersion() error
- func (s *Store) LoadVersion(version uint64) error
- func (s *Store) LoadVersionAndUpgrade(version uint64, upgrades *corestore.StoreUpgrades) error
- func (s *Store) LoadVersionForOverwriting(version uint64) error
- func (s *Store) Prune(version uint64) error
- func (s *Store) Query(storeKey []byte, version uint64, key []byte, prove bool) (store.QueryResult, error)
- func (s *Store) SetInitialVersion(v uint64) error
- func (s *Store) SetMetrics(m metrics.Metrics)
- func (s *Store) StateAt(v uint64) (corestore.ReaderMap, error)
- func (s *Store) StateLatest() (uint64, corestore.ReaderMap, error)
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:
- Namespace registration
- 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.
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 ¶
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 ¶
Close closes the store and resets all internal fields. Note, Close() is NOT idempotent and should only be called once.
func (*Store) Commit ¶
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 ¶
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 ¶
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 (*Store) LoadVersion ¶
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.