store

package
v0.11.14 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: Apache-2.0 Imports: 17 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateKey

func GenerateKey(fields []interface{}) string

GenerateKey ...

func NewDefaultInMemoryKVStore

func NewDefaultInMemoryKVStore() (ds.TxnDatastore, error)

NewDefaultInMemoryKVStore builds KVStore that works in-memory (without accessing disk).

func NewDefaultKVStore

func NewDefaultKVStore(rootDir, dbPath, dbName string) (ds.TxnDatastore, error)

NewDefaultKVStore creates instance of default key-value store.

func PrefixEntries

func PrefixEntries(ctx context.Context, store ds.Datastore, prefix string) (dsq.Results, error)

PrefixEntries retrieves all entries in the datastore whose keys have the supplied prefix

Types

type DefaultStore

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

DefaultStore is a default store implmementation.

func (*DefaultStore) GetBlock added in v0.10.7

func (s *DefaultStore) GetBlock(height uint64) (*types.Block, error)

GetBlock returns block at given height, or error if it's not found in Store. TODO(tzdybal): what is more common access pattern? by height or by hash? currently, we're indexing height->hash, and store blocks by hash, but we might as well store by height and index hash->height

func (*DefaultStore) GetBlockByHash added in v0.10.7

func (s *DefaultStore) GetBlockByHash(hash types.Hash) (*types.Block, error)

GetBlockByHash returns block with given block header hash, or error if it's not found in Store.

func (*DefaultStore) GetBlockResponses added in v0.10.7

func (s *DefaultStore) GetBlockResponses(height uint64) (*abci.ResponseFinalizeBlock, error)

GetBlockResponses returns block results at given height, or error if it's not found in Store.

func (*DefaultStore) GetCommit added in v0.10.7

func (s *DefaultStore) GetCommit(height uint64) (*types.Commit, error)

GetCommit returns commit for a block at given height, or error if it's not found in Store.

func (*DefaultStore) GetCommitByHash added in v0.10.7

func (s *DefaultStore) GetCommitByHash(hash types.Hash) (*types.Commit, error)

GetCommitByHash returns commit for a block with given block header hash, or error if it's not found in Store.

func (*DefaultStore) GetState added in v0.10.7

func (s *DefaultStore) GetState() (types.State, error)

GetState returns last state saved with UpdateState.

func (*DefaultStore) Height

func (s *DefaultStore) Height() uint64

Height returns height of the highest block saved in the Store.

func (*DefaultStore) SaveBlock

func (s *DefaultStore) SaveBlock(block *types.Block, commit *types.Commit) error

SaveBlock adds block to the store along with corresponding commit. Stored height is updated if block height is greater than stored value.

func (*DefaultStore) SaveBlockResponses

func (s *DefaultStore) SaveBlockResponses(height uint64, responses *abci.ResponseFinalizeBlock) error

SaveBlockResponses saves block responses (events, tx responses, validator set updates, etc) in Store.

func (*DefaultStore) SetHeight

func (s *DefaultStore) SetHeight(height uint64)

SetHeight sets the height saved in the Store if it is higher than the existing height

func (*DefaultStore) UpdateState

func (s *DefaultStore) UpdateState(state types.State) error

UpdateState updates state saved in Store. Only one State is stored. If there is no State in Store, state will be saved.

type Store

type Store interface {
	// Height returns height of the highest block in store.
	Height() uint64

	// SetHeight sets the height saved in the Store if it is higher than the existing height.
	SetHeight(height uint64)

	// SaveBlock saves block along with its seen commit (which will be included in the next block).
	SaveBlock(block *types.Block, commit *types.Commit) error

	// GetBlock returns block at given height, or error if it's not found in Store.
	GetBlock(height uint64) (*types.Block, error)
	// GetBlockByHash returns block with given block header hash, or error if it's not found in Store.
	GetBlockByHash(hash types.Hash) (*types.Block, error)

	// SaveBlockResponses saves block responses (events, tx responses, validator set updates, etc) in Store.
	SaveBlockResponses(height uint64, responses *abci.ResponseFinalizeBlock) error

	// GetBlockResponses returns block results at given height, or error if it's not found in Store.
	GetBlockResponses(height uint64) (*abci.ResponseFinalizeBlock, error)

	// GetCommit returns commit for a block at given height, or error if it's not found in Store.
	GetCommit(height uint64) (*types.Commit, error)
	// GetCommitByHash returns commit for a block with given block header hash, or error if it's not found in Store.
	GetCommitByHash(hash types.Hash) (*types.Commit, error)

	// UpdateState updates state saved in Store. Only one State is stored.
	// If there is no State in Store, state will be saved.
	UpdateState(state types.State) error
	// GetState returns last state saved with UpdateState.
	GetState() (types.State, error)
}

Store is minimal interface for storing and retrieving blocks, commits and state.

func New

func New(ctx context.Context, ds ds.TxnDatastore) Store

New returns new, default store.

Jump to

Keyboard shortcuts

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