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