root

package
v2.0.0-...-80ba18e Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: Apache-2.0 Imports: 23 Imported by: 1

Documentation

Index

Constants

View Source
const (
	SSTypeSQLite SSType = 0
	SSTypePebble SSType = 1
	SSTypeRocks  SSType = 2
	SCTypeIavl   SCType = 0
	SCTypeIavlV2 SCType = 1
)

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(
	logger log.Logger,
	ss store.VersionedDatabase,
	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 FactoryOptions

type FactoryOptions struct {
	Logger         log.Logger
	RootDir        string
	SSType         SSType
	SCType         SCType
	SSPruneOptions *store.PruneOptions
	SCPruneOptions *store.PruneOptions
	IavlConfig     *iavl.Config
	StoreKeys      []string
	SCRawDB        corestore.KVStoreWithBatch
}

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, rs store.RootStore, 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, rs store.RootStore) *ReaderMap

func (*ReaderMap) GetReader

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

type SCType

type SCType int

type SSType

type SSType int

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

func (s *Store) GetStateStorage() store.VersionedDatabase

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

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

func (*Store) SetCommitHeader

func (s *Store) SetCommitHeader(h *coreheader.Info)

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)

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