Documentation
¶
Index ¶
- func GenerateKey(fields []interface{}) string
- func NewDefaultInMemoryKVStore() (ds.TxnDatastore, error)
- func NewDefaultKVStore(rootDir, dbPath, dbName string) (ds.TxnDatastore, error)
- func PrefixEntries(ctx context.Context, store ds.Datastore, prefix string) (dsq.Results, error)
- type DefaultStore
- func (s *DefaultStore) Height() uint64
- func (s *DefaultStore) LoadBlock(height uint64) (*types.Block, error)
- func (s *DefaultStore) LoadBlockByHash(hash types.Hash) (*types.Block, error)
- func (s *DefaultStore) LoadBlockResponses(height uint64) (*cmstate.ABCIResponses, error)
- func (s *DefaultStore) LoadCommit(height uint64) (*types.Commit, error)
- func (s *DefaultStore) LoadCommitByHash(hash types.Hash) (*types.Commit, error)
- func (s *DefaultStore) LoadState() (types.State, error)
- func (s *DefaultStore) LoadValidators(height uint64) (*cmtypes.ValidatorSet, error)
- func (s *DefaultStore) SaveBlock(block *types.Block, commit *types.Commit) error
- func (s *DefaultStore) SaveBlockResponses(height uint64, responses *cmstate.ABCIResponses) error
- func (s *DefaultStore) SaveValidators(height uint64, validatorSet *cmtypes.ValidatorSet) error
- func (s *DefaultStore) SetHeight(height uint64)
- func (s *DefaultStore) UpdateState(state types.State) error
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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.
Types ¶
type DefaultStore ¶
type DefaultStore struct {
// contains filtered or unexported fields
}
DefaultStore is a default store implmementation.
func (*DefaultStore) Height ¶
func (s *DefaultStore) Height() uint64
Height returns height of the highest block saved in the Store.
func (*DefaultStore) LoadBlock ¶
func (s *DefaultStore) LoadBlock(height uint64) (*types.Block, error)
LoadBlock 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) LoadBlockByHash ¶
LoadBlockByHash returns block with given block header hash, or error if it's not found in Store.
func (*DefaultStore) LoadBlockResponses ¶
func (s *DefaultStore) LoadBlockResponses(height uint64) (*cmstate.ABCIResponses, error)
LoadBlockResponses returns block results at given height, or error if it's not found in Store.
func (*DefaultStore) LoadCommit ¶
func (s *DefaultStore) LoadCommit(height uint64) (*types.Commit, error)
LoadCommit returns commit for a block at given height, or error if it's not found in Store.
func (*DefaultStore) LoadCommitByHash ¶
LoadCommitByHash returns commit for a block with given block header hash, or error if it's not found in Store.
func (*DefaultStore) LoadState ¶
func (s *DefaultStore) LoadState() (types.State, error)
LoadState returns last state saved with UpdateState.
func (*DefaultStore) LoadValidators ¶
func (s *DefaultStore) LoadValidators(height uint64) (*cmtypes.ValidatorSet, error)
LoadValidators loads validator set at given block height from store.
func (*DefaultStore) SaveBlock ¶
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 *cmstate.ABCIResponses) error
SaveBlockResponses saves block responses (events, tx responses, validator set updates, etc) in Store.
func (*DefaultStore) SaveValidators ¶
func (s *DefaultStore) SaveValidators(height uint64, validatorSet *cmtypes.ValidatorSet) error
SaveValidators stores validator set for given block height 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
// LoadBlock returns block at given height, or error if it's not found in Store.
LoadBlock(height uint64) (*types.Block, error)
// LoadBlockByHash returns block with given block header hash, or error if it's not found in Store.
LoadBlockByHash(hash types.Hash) (*types.Block, error)
// SaveBlockResponses saves block responses (events, tx responses, validator set updates, etc) in Store.
SaveBlockResponses(height uint64, responses *cmstate.ABCIResponses) error
// LoadBlockResponses returns block results at given height, or error if it's not found in Store.
LoadBlockResponses(height uint64) (*cmstate.ABCIResponses, error)
// LoadCommit returns commit for a block at given height, or error if it's not found in Store.
LoadCommit(height uint64) (*types.Commit, error)
// LoadCommitByHash returns commit for a block with given block header hash, or error if it's not found in Store.
LoadCommitByHash(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
// LoadState returns last state saved with UpdateState.
LoadState() (types.State, error)
SaveValidators(height uint64, validatorSet *cmtypes.ValidatorSet) error
LoadValidators(height uint64) (*cmtypes.ValidatorSet, error)
}
Store is minimal interface for storing and retrieving blocks, commits and state.