forked from onflow/flow-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
headers.go
36 lines (27 loc) · 1.37 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
// (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 returns 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)
}