Documentation
¶
Index ¶
- func GenerateKey(fields []string) 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) Close() error
- func (s *DefaultStore) GetBlockByHash(ctx context.Context, hash types.Hash) (*types.SignedHeader, *types.Data, error)
- func (s *DefaultStore) GetBlockData(ctx context.Context, height uint64) (*types.SignedHeader, *types.Data, error)
- func (s *DefaultStore) GetBlockResponses(ctx context.Context, height uint64) (*abci.ResponseFinalizeBlock, error)
- func (s *DefaultStore) GetExtendedCommit(ctx context.Context, height uint64) (*abci.ExtendedCommitInfo, error)
- func (s *DefaultStore) GetMetadata(ctx context.Context, key string) ([]byte, error)
- func (s *DefaultStore) GetSignature(ctx context.Context, height uint64) (*types.Signature, error)
- func (s *DefaultStore) GetSignatureByHash(ctx context.Context, hash types.Hash) (*types.Signature, error)
- func (s *DefaultStore) GetState(ctx context.Context) (types.State, error)
- func (s *DefaultStore) Height() uint64
- func (s *DefaultStore) SaveBlockData(ctx context.Context, header *types.SignedHeader, data *types.Data, ...) error
- func (s *DefaultStore) SaveBlockResponses(ctx context.Context, height uint64, responses *abci.ResponseFinalizeBlock) error
- func (s *DefaultStore) SaveExtendedCommit(ctx context.Context, height uint64, commit *abci.ExtendedCommitInfo) error
- func (s *DefaultStore) SetHeight(ctx context.Context, height uint64)
- func (s *DefaultStore) SetMetadata(ctx context.Context, key string, value []byte) error
- func (s *DefaultStore) UpdateState(ctx context.Context, state types.State) error
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateKey ¶
GenerateKey creates a key from a slice of string fields, joining them with slashes.
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) Close ¶ added in v0.13.0
func (s *DefaultStore) Close() error
Close safely closes underlying data storage, to ensure that data is actually saved.
func (*DefaultStore) GetBlockByHash ¶ added in v0.10.7
func (s *DefaultStore) GetBlockByHash(ctx context.Context, hash types.Hash) (*types.SignedHeader, *types.Data, error)
GetBlockByHash returns block with given block header hash, or error if it's not found in Store.
func (*DefaultStore) GetBlockData ¶ added in v0.14.0
func (s *DefaultStore) GetBlockData(ctx context.Context, height uint64) (*types.SignedHeader, *types.Data, error)
GetBlockData returns block header and data 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) GetBlockResponses ¶ added in v0.10.7
func (s *DefaultStore) GetBlockResponses(ctx context.Context, height uint64) (*abci.ResponseFinalizeBlock, error)
GetBlockResponses returns block results at given height, or error if it's not found in Store.
func (*DefaultStore) GetExtendedCommit ¶ added in v0.13.3
func (s *DefaultStore) GetExtendedCommit(ctx context.Context, height uint64) (*abci.ExtendedCommitInfo, error)
GetExtendedCommit returns extended commit (commit with vote extensions) for a block at given height.
func (*DefaultStore) GetMetadata ¶ added in v0.13.0
GetMetadata returns values stored for given key with SetMetadata.
func (*DefaultStore) GetSignature ¶ added in v0.13.6
GetSignature returns signature for a block at given height, or error if it's not found in Store.
func (*DefaultStore) GetSignatureByHash ¶ added in v0.13.6
func (s *DefaultStore) GetSignatureByHash(ctx context.Context, hash types.Hash) (*types.Signature, error)
GetSignatureByHash returns signature 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
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) SaveBlockData ¶ added in v0.14.0
func (s *DefaultStore) SaveBlockData(ctx context.Context, header *types.SignedHeader, data *types.Data, signature *types.Signature) error
SaveBlockData adds block header and data to the store along with corresponding signature. Stored height is updated if block height is greater than stored value.
func (*DefaultStore) SaveBlockResponses ¶
func (s *DefaultStore) SaveBlockResponses(ctx context.Context, height uint64, responses *abci.ResponseFinalizeBlock) error
SaveBlockResponses saves block responses (events, tx responses, validator set updates, etc) in Store.
func (*DefaultStore) SaveExtendedCommit ¶ added in v0.13.3
func (s *DefaultStore) SaveExtendedCommit(ctx context.Context, height uint64, commit *abci.ExtendedCommitInfo) error
SaveExtendedCommit saves extended commit information in Store.
func (*DefaultStore) SetHeight ¶
func (s *DefaultStore) SetHeight(ctx context.Context, height uint64)
SetHeight sets the height saved in the Store if it is higher than the existing height
func (*DefaultStore) SetMetadata ¶ added in v0.13.0
SetMetadata saves arbitrary value in the store.
Metadata is separated from other data by using prefix in KV.
func (*DefaultStore) UpdateState ¶
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(ctx context.Context, height uint64)
// SaveBlock saves block along with its seen signature (which will be included in the next block).
SaveBlockData(ctx context.Context, header *types.SignedHeader, data *types.Data, signature *types.Signature) error
// GetBlock returns block at given height, or error if it's not found in Store.
GetBlockData(ctx context.Context, height uint64) (*types.SignedHeader, *types.Data, error)
// GetBlockByHash returns block with given block header hash, or error if it's not found in Store.
GetBlockByHash(ctx context.Context, hash types.Hash) (*types.SignedHeader, *types.Data, error)
// SaveBlockResponses saves block responses (events, tx responses, validator set updates, etc) in Store.
SaveBlockResponses(ctx context.Context, height uint64, responses *abci.ResponseFinalizeBlock) error
// GetBlockResponses returns block results at given height, or error if it's not found in Store.
GetBlockResponses(ctx context.Context, height uint64) (*abci.ResponseFinalizeBlock, error)
// GetSignature returns signature for a block at given height, or error if it's not found in Store.
GetSignature(ctx context.Context, height uint64) (*types.Signature, error)
// GetSignatureByHash returns signature for a block with given block header hash, or error if it's not found in Store.
GetSignatureByHash(ctx context.Context, hash types.Hash) (*types.Signature, error)
// SaveExtendedCommit saves extended commit information in Store.
SaveExtendedCommit(ctx context.Context, height uint64, commit *abci.ExtendedCommitInfo) error
// GetExtendedCommit returns extended commit (commit with vote extensions) for a block at given height.
GetExtendedCommit(ctx context.Context, height uint64) (*abci.ExtendedCommitInfo, error)
// UpdateState updates state saved in Store. Only one State is stored.
// If there is no State in Store, state will be saved.
UpdateState(ctx context.Context, state types.State) error
// GetState returns last state saved with UpdateState.
GetState(ctx context.Context) (types.State, error)
// SetMetadata saves arbitrary value in the store.
//
// This method enables rollkit to safely persist any information.
SetMetadata(ctx context.Context, key string, value []byte) error
// GetMetadata returns values stored for given key with SetMetadata.
GetMetadata(ctx context.Context, key string) ([]byte, error)
// Close safely closes underlying data storage, to ensure that data is actually saved.
Close() error
}
Store is minimal interface for storing and retrieving blocks, commits and state.