Documentation ¶
Overview ¶
Package storage defines the interface and implementations for interacting with persistent chain state.
Index ¶
- Variables
- type DataGetter
- type DataSetter
- type DefaultKeyGenerator
- func (s *DefaultKeyGenerator) BlockHeight(blockHeight uint64) []byte
- func (s *DefaultKeyGenerator) Event(blockHeight uint64, txIndex, eventIndex uint32, eventType flowgo.EventType) []byte
- func (s *DefaultKeyGenerator) Identifier(id flowgo.Identifier) []byte
- func (s *DefaultKeyGenerator) LatestBlock() []byte
- func (s *DefaultKeyGenerator) Storage(key string) string
- 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) InsertLedgerDelta(ctx context.Context, blockHeight uint64, delta delta.Delta) 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) LedgerViewByHeight(ctx context.Context, blockHeight uint64) *delta.View
- 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 Store
Constants ¶
This section is empty.
Variables ¶
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 }
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, delta delta.Delta, 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) InsertLedgerDelta ¶ added in v0.40.0
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) LedgerViewByHeight ¶ added in v0.40.0
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 Store ¶
type Store interface { LatestBlockHeight(ctx context.Context) (uint64, error) // LatestBlock returns the block with the highest block height. LatestBlock(ctx context.Context) (flowgo.Block, error) // Store stores the block. 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, delta delta.Delta, 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) // LedgerViewByHeight returns a view into the ledger state at a given block. LedgerViewByHeight(ctx context.Context, blockHeight uint64) *delta.View // 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.