forked from onflow/flow-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheaders.go
50 lines (37 loc) · 2.14 KB
/
headers.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
46
47
48
49
50
// (c) 2019 Dapper Labs - ALL RIGHTS RESERVED
package storage
import (
"github.com/onflow/flow-go/model/flow"
)
// Headers represents persistent storage for blocks.
type Headers interface {
// Store will store a header.
Store(header *flow.Header) error
// ByBlockID returns the header with the given ID. It is available for finalized and ambiguous blocks.
// Error returns:
// - ErrNotFound if no block header with the given ID exists
ByBlockID(blockID flow.Identifier) (*flow.Header, error)
// ByHeight returns the block with the given number. It is only available for finalized blocks.
ByHeight(height uint64) (*flow.Header, error)
// Exists returns true if a header with the given ID has been stored.
// No errors are expected during normal operation.
Exists(blockID flow.Identifier) (bool, error)
// BlockIDByHeight the block ID that is finalized at the given height. It is an optimized version
// of `ByHeight` that skips retrieving the block. Expected errors during normal operations:
// * `storage.ErrNotFound` if no finalized block is known at given height
BlockIDByHeight(height uint64) (flow.Identifier, error)
// ByParentID finds all children for the given parent block. The returned headers
// might be unfinalized; if there is more than one, at least one of them has to
// be unfinalized.
ByParentID(parentID flow.Identifier) ([]*flow.Header, error)
// IndexByChunkID indexes block ID by chunk ID.
IndexByChunkID(headerID, chunkID flow.Identifier) error
// BatchIndexByChunkID indexes block ID by chunk ID in a given batch.
BatchIndexByChunkID(headerID, chunkID flow.Identifier, batch BatchStorage) error
// IDByChunkID finds the ID of the block corresponding to given chunk ID.
IDByChunkID(chunkID flow.Identifier) (flow.Identifier, error)
// BatchRemoveChunkBlockIndexByChunkID removes block to chunk index entry keyed by a blockID in a provided batch
// No errors are expected during normal operation, even if no entries are matched.
// If Badger unexpectedly fails to process the request, the error is wrapped in a generic error and returned.
BatchRemoveChunkBlockIndexByChunkID(chunkID flow.Identifier, batch BatchStorage) error
}