github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/storage/blocks.go (about) 1 package storage 2 3 import ( 4 "github.com/onflow/flow-go/model/flow" 5 "github.com/onflow/flow-go/storage/badger/transaction" 6 ) 7 8 // Blocks represents persistent storage for blocks. 9 type Blocks interface { 10 11 // Store will atomically store a block with all its dependencies. 12 Store(block *flow.Block) error 13 14 // StoreTx allows us to store a new block, including its payload & header, as part of a DB transaction, while 15 // still going through the caching layer. 16 StoreTx(block *flow.Block) func(*transaction.Tx) error 17 18 // ByID returns the block with the given hash. It is available for 19 // finalized and ambiguous blocks. 20 ByID(blockID flow.Identifier) (*flow.Block, error) 21 22 // ByHeight returns the block at the given height. It is only available 23 // for finalized blocks. 24 ByHeight(height uint64) (*flow.Block, error) 25 26 // ByCollectionID returns the block for the given collection ID. 27 ByCollectionID(collID flow.Identifier) (*flow.Block, error) 28 29 // IndexBlockForCollections indexes the block each collection was 30 // included in. 31 IndexBlockForCollections(blockID flow.Identifier, collIDs []flow.Identifier) error 32 }