-
Notifications
You must be signed in to change notification settings - Fork 179
/
blocks.go
45 lines (33 loc) · 1.69 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
33
34
35
36
37
38
39
40
41
42
43
44
45
// (c) 2019 Dapper Labs - ALL RIGHTS RESERVED
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
// InsertLastFullBlockHeightIfNotExists inserts the FullBlockHeight index if it does not already exist.
// Calling this function multiple times is a no-op and returns no expected errors.
InsertLastFullBlockHeightIfNotExists(height uint64) error
// UpdateLastFullBlockHeight updates the FullBlockHeight index
// The FullBlockHeight index indicates that block for which all collections have been received
UpdateLastFullBlockHeight(height uint64) error
// GetLastFullBlockHeight retrieves the FullBlockHeight
GetLastFullBlockHeight() (height uint64, err error)
}