Documentation
¶
Index ¶
- Constants
- func GenerateKey(fields []string) string
- func NewDefaultInMemoryKVStore() (ds.Batching, error)
- func NewDefaultKVStore(rootDir, dbPath, dbName string) (ds.Batching, 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 []byte) (*types.SignedHeader, *types.Data, error)
- func (s *DefaultStore) GetBlockData(ctx context.Context, height uint64) (*types.SignedHeader, *types.Data, error)
- func (s *DefaultStore) GetHeader(ctx context.Context, height uint64) (*types.SignedHeader, 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 []byte) (*types.Signature, error)
- func (s *DefaultStore) GetState(ctx context.Context) (types.State, error)
- func (s *DefaultStore) GetStateAtHeight(ctx context.Context, height uint64) (types.State, error)
- func (s *DefaultStore) Height(ctx context.Context) (uint64, error)
- func (s *DefaultStore) Rollback(ctx context.Context, height uint64, aggregator bool) error
- func (s *DefaultStore) SaveBlockData(ctx context.Context, header *types.SignedHeader, data *types.Data, ...) error
- func (s *DefaultStore) SetHeight(ctx context.Context, height uint64) error
- 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 ¶
const ( // GenesisDAHeightKey is the key used for persisting the first DA included height in store. // It avoids to walk over the HeightToDAHeightKey to find the first DA included height. GenesisDAHeightKey = "gdh" // HeightToDAHeightKey is the key prefix used for persisting the mapping from a Evolve height // to the DA height where the block's header/data was included. // Full keys are like: rhb/<evolve_height>/h and rhb/<evolve_height>/d HeightToDAHeightKey = "rhb" // DAIncludedHeightKey is the key used for persisting the da included height in store. DAIncludedHeightKey = "d" // LastBatchDataKey is the key used for persisting the last batch data in store. LastBatchDataKey = "l" // LastSubmittedHeaderHeightKey is the key used for persisting the last submitted header height in store. LastSubmittedHeaderHeightKey = "last-submitted-header-height" )
Variables ¶
This section is empty.
Functions ¶
func GenerateKey ¶
GenerateKey creates a key from a slice of string fields, joining them with slashes.
func NewDefaultInMemoryKVStore ¶
NewDefaultInMemoryKVStore builds KVStore that works in-memory (without accessing disk).
func NewDefaultKVStore ¶
NewDefaultKVStore creates instance of default key-value store.
Types ¶
type DefaultStore ¶
type DefaultStore struct {
// contains filtered or unexported fields
}
DefaultStore is a default store implementation.
func (*DefaultStore) Close ¶
func (s *DefaultStore) Close() error
Close safely closes underlying data storage, to ensure that data is actually saved.
func (*DefaultStore) GetBlockByHash ¶
func (s *DefaultStore) GetBlockByHash(ctx context.Context, hash []byte) (*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 ¶
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.
func (*DefaultStore) GetHeader ¶
func (s *DefaultStore) GetHeader(ctx context.Context, height uint64) (*types.SignedHeader, error)
GetHeader returns the header at the given height or error if it's not found in Store.
func (*DefaultStore) GetMetadata ¶
GetMetadata returns values stored for given key with SetMetadata.
func (*DefaultStore) GetSignature ¶
GetSignature returns signature for a block with given block header hash, or error if it's not found in Store.
func (*DefaultStore) GetSignatureByHash ¶
func (s *DefaultStore) GetSignatureByHash(ctx context.Context, hash []byte) (*types.Signature, error)
GetSignatureByHash returns signature for a block at given height, or error if it's not found in Store.
func (*DefaultStore) GetStateAtHeight ¶
GetStateAtHeight returns the state at the given height. If no state is stored at that height, it returns an error.
func (*DefaultStore) Height ¶
func (s *DefaultStore) Height(ctx context.Context) (uint64, error)
Height returns height of the highest block saved in the Store.
func (*DefaultStore) Rollback ¶
Rollback rolls back block data until the given height from the store. When aggregator is true, it will check the latest data included height and prevent rollback further than that. NOTE: this function does not rollback metadata. Those should be handled separately if required. Other stores are not rolled back either.
func (*DefaultStore) SaveBlockData ¶
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) SetHeight ¶
func (s *DefaultStore) SetHeight(ctx context.Context, height uint64) error
SetHeight sets the height saved in the Store if it is higher than the existing height
func (*DefaultStore) SetMetadata ¶
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(ctx context.Context) (uint64, error)
// SetHeight sets the height saved in the Store if it is higher than the existing height.
SetHeight(ctx context.Context, height uint64) error
// SaveBlockData 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
// GetBlockData 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 []byte) (*types.SignedHeader, *types.Data, error)
// GetHeader returns the header at the given height or error if it's not found in Store.
GetHeader(ctx context.Context, height uint64) (*types.SignedHeader, 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 []byte) (*types.Signature, 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)
// GetStateAtHeight returns state saved at given height, or error if it's not found in Store.
GetStateAtHeight(ctx context.Context, height uint64) (types.State, error)
// SetMetadata saves arbitrary value in the store.
//
// This method enables evolve 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)
// Rollback deletes x height from the ev-node store.
// Aggregator is used to determine if the rollback is performed on the aggregator node.
Rollback(ctx context.Context, height uint64, aggregator bool) 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.