Documentation ¶
Overview ¶
Package storage defines the interface and implementations for interacting with persistent chain state.
Index ¶
- Constants
- Variables
- type DataGetter
- type DataSetter
- type DefaultKeyGenerator
- type DefaultStore
- func (s *DefaultStore) BlockByHeight(ctx context.Context, blockHeight uint64) (block *flowgo.Block, err error)
- func (s *DefaultStore) BlockByID(ctx context.Context, blockID flowgo.Identifier) (block *flowgo.Block, err error)
- func (s *DefaultStore) CollectionByID(ctx context.Context, colID flowgo.Identifier) (col flowgo.LightCollection, err error)
- func (s *DefaultStore) CommitBlock(ctx context.Context, block flowgo.Block, collections []*flowgo.LightCollection, ...) error
- func (s *DefaultStore) EventsByHeight(ctx context.Context, blockHeight uint64, eventType string) (events []flowgo.Event, err error)
- func (s *DefaultStore) InsertCollection(ctx context.Context, col flowgo.LightCollection) error
- func (s *DefaultStore) InsertEvents(ctx context.Context, blockHeight uint64, events []flowgo.Event) error
- func (s *DefaultStore) InsertExecutionSnapshot(ctx context.Context, blockHeight uint64, ...) error
- func (s *DefaultStore) InsertTransaction(ctx context.Context, tx flowgo.TransactionBody) error
- func (s *DefaultStore) InsertTransactionResult(ctx context.Context, txID flowgo.Identifier, ...) error
- func (s *DefaultStore) LatestBlock(ctx context.Context) (block flowgo.Block, err error)
- func (s *DefaultStore) LatestBlockHeight(ctx context.Context) (latestBlockHeight uint64, err error)
- func (s *DefaultStore) LedgerByHeight(ctx context.Context, blockHeight uint64) (snapshot.StorageSnapshot, error)
- func (s *DefaultStore) SetBlockHeight(height uint64) error
- func (s *DefaultStore) Start() error
- func (s *DefaultStore) Stop()
- func (s *DefaultStore) StoreBlock(ctx context.Context, block *flowgo.Block) error
- func (s *DefaultStore) TransactionByID(ctx context.Context, txID flowgo.Identifier) (tx flowgo.TransactionBody, err error)
- func (s *DefaultStore) TransactionResultByID(ctx context.Context, txID flowgo.Identifier) (result types.StorableTransactionResult, err error)
- type KeyGenerator
- type RollbackProvider
- type SnapshotProvider
- type Store
Constants ¶
View Source
const ( BlockIndexStoreName = "blockIndex" BlockStoreName = "blocks" CollectionStoreName = "collections" TransactionStoreName = "transactions" TransactionResultStoreName = "transactionResults" EventStoreName = "events" LedgerStoreName = "ledger" )
Variables ¶
View Source
var ErrNotFound = errors.New("could not find entity")
ErrNotFound is an error returned when an entity cannot be found.
Functions ¶
This section is empty.
Types ¶
type DataGetter ¶ added in v0.40.0
type DataSetter ¶ added in v0.40.0
type DefaultKeyGenerator ¶ added in v0.40.0
type DefaultKeyGenerator struct { }
func (*DefaultKeyGenerator) BlockHeight ¶ added in v0.40.0
func (s *DefaultKeyGenerator) BlockHeight(blockHeight uint64) []byte
func (*DefaultKeyGenerator) Identifier ¶ added in v0.40.0
func (s *DefaultKeyGenerator) Identifier(id flowgo.Identifier) []byte
func (*DefaultKeyGenerator) LatestBlock ¶ added in v0.40.0
func (s *DefaultKeyGenerator) LatestBlock() []byte
func (*DefaultKeyGenerator) Storage ¶ added in v0.40.0
func (s *DefaultKeyGenerator) Storage(key string) string
type DefaultStore ¶ added in v0.40.0
type DefaultStore struct { KeyGenerator DataSetter DataGetter CurrentHeight uint64 }
func (*DefaultStore) BlockByHeight ¶ added in v0.40.0
func (*DefaultStore) BlockByID ¶ added in v0.40.0
func (s *DefaultStore) BlockByID(ctx context.Context, blockID flowgo.Identifier) (block *flowgo.Block, err error)
func (*DefaultStore) CollectionByID ¶ added in v0.40.0
func (s *DefaultStore) CollectionByID( ctx context.Context, colID flowgo.Identifier, ) ( col flowgo.LightCollection, err error, )
func (*DefaultStore) CommitBlock ¶ added in v0.40.0
func (s *DefaultStore) CommitBlock( ctx context.Context, block flowgo.Block, collections []*flowgo.LightCollection, transactions map[flowgo.Identifier]*flowgo.TransactionBody, transactionResults map[flowgo.Identifier]*types.StorableTransactionResult, executionSnapshot *snapshot.ExecutionSnapshot, events []flowgo.Event, ) error
func (*DefaultStore) EventsByHeight ¶ added in v0.40.0
func (*DefaultStore) InsertCollection ¶ added in v0.40.0
func (s *DefaultStore) InsertCollection(ctx context.Context, col flowgo.LightCollection) error
func (*DefaultStore) InsertEvents ¶ added in v0.40.0
func (*DefaultStore) InsertExecutionSnapshot ¶ added in v0.46.0
func (s *DefaultStore) InsertExecutionSnapshot( ctx context.Context, blockHeight uint64, executionSnapshot *snapshot.ExecutionSnapshot, ) error
func (*DefaultStore) InsertTransaction ¶ added in v0.40.0
func (s *DefaultStore) InsertTransaction(ctx context.Context, tx flowgo.TransactionBody) error
func (*DefaultStore) InsertTransactionResult ¶ added in v0.40.0
func (s *DefaultStore) InsertTransactionResult( ctx context.Context, txID flowgo.Identifier, result types.StorableTransactionResult, ) error
func (*DefaultStore) LatestBlock ¶ added in v0.40.0
func (*DefaultStore) LatestBlockHeight ¶ added in v0.40.0
func (s *DefaultStore) LatestBlockHeight(ctx context.Context) (latestBlockHeight uint64, err error)
func (*DefaultStore) LedgerByHeight ¶ added in v0.46.0
func (s *DefaultStore) LedgerByHeight( ctx context.Context, blockHeight uint64, ) (snapshot.StorageSnapshot, error)
func (*DefaultStore) SetBlockHeight ¶ added in v0.46.0
func (s *DefaultStore) SetBlockHeight(height uint64) error
func (*DefaultStore) Start ¶ added in v0.46.0
func (s *DefaultStore) Start() error
func (*DefaultStore) Stop ¶ added in v0.46.0
func (s *DefaultStore) Stop()
func (*DefaultStore) StoreBlock ¶ added in v0.40.0
func (*DefaultStore) TransactionByID ¶ added in v0.40.0
func (s *DefaultStore) TransactionByID( ctx context.Context, txID flowgo.Identifier, ) ( tx flowgo.TransactionBody, err error, )
func (*DefaultStore) TransactionResultByID ¶ added in v0.40.0
func (s *DefaultStore) TransactionResultByID( ctx context.Context, txID flowgo.Identifier, ) ( result types.StorableTransactionResult, err error, )
type KeyGenerator ¶ added in v0.40.0
type RollbackProvider ¶ added in v0.46.0
type SnapshotProvider ¶ added in v0.44.0
type Store ¶
type Store interface { graceland.Routine LatestBlockHeight(ctx context.Context) (uint64, error) // LatestBlock returns the block with the highest block height. LatestBlock(ctx context.Context) (flowgo.Block, error) // StoreBlock stores the block in storage. If the exactly same block is already in a storage, return successfully StoreBlock(ctx context.Context, block *flowgo.Block) error // BlockByID returns the block with the given hash. It is available for // finalized and ambiguous blocks. BlockByID(ctx context.Context, blockID flowgo.Identifier) (*flowgo.Block, error) // BlockByHeight returns the block at the given height. It is only available // for finalized blocks. BlockByHeight(ctx context.Context, height uint64) (*flowgo.Block, error) // CommitBlock atomically saves the execution results for a block. CommitBlock( ctx context.Context, block flowgo.Block, collections []*flowgo.LightCollection, transactions map[flowgo.Identifier]*flowgo.TransactionBody, transactionResults map[flowgo.Identifier]*types.StorableTransactionResult, executionSnapshot *snapshot.ExecutionSnapshot, events []flowgo.Event, ) error // CollectionByID gets the collection (transaction IDs only) with the given ID. CollectionByID(ctx context.Context, collectionID flowgo.Identifier) (flowgo.LightCollection, error) // TransactionByID gets the transaction with the given ID. TransactionByID(ctx context.Context, transactionID flowgo.Identifier) (flowgo.TransactionBody, error) // TransactionResultByID gets the transaction result with the given ID. TransactionResultByID(ctx context.Context, transactionID flowgo.Identifier) (types.StorableTransactionResult, error) // LedgerByHeight returns a storage snapshot into the ledger state // at a given block. LedgerByHeight( ctx context.Context, blockHeight uint64, ) (snapshot.StorageSnapshot, error) // EventsByHeight returns the events in the block at the given height, optionally filtered by type. EventsByHeight(ctx context.Context, blockHeight uint64, eventType string) ([]flowgo.Event, error) }
Store defines the storage layer for persistent chain state.
This includes finalized blocks and transactions, and the resultant register states and emitted events. It does not include pending state, such as pending transactions and register states.
Implementations must distinguish between not found errors and errors with the underlying storage by returning an instance of store.ErrNotFound if a resource cannot be found.
Implementations must be safe for use by multiple goroutines.
Click to show internal directories.
Click to hide internal directories.