/
history.go
41 lines (32 loc) · 1.33 KB
/
history.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
package api
import (
"context"
"github.com/oasisprotocol/oasis-core/go/common"
"github.com/oasisprotocol/oasis-core/go/roothash/api/block"
)
// BlockHistory is the root hash block history keeper interface.
//
// All methods operate on a specific runtime.
type BlockHistory interface {
// RuntimeID returns the runtime ID of the runtime this block history is for.
RuntimeID() common.Namespace
// Commit commits an annotated block into history.
//
// Must be called in order, sorted by round.
Commit(blk *AnnotatedBlock, roundResults *RoundResults) error
// ConsensusCheckpoint records the last consensus height which was processed
// by the roothash backend.
//
// This method can only be called once all roothash blocks for consensus
// heights <= height have been committed using Commit.
ConsensusCheckpoint(height int64) error
// LastConsensusHeight returns the last consensus height which was seen
// by block history.
LastConsensusHeight() (int64, error)
// GetBlock returns the block at a specific round.
GetBlock(ctx context.Context, round uint64) (*block.Block, error)
// GetLatestBlock returns the block at latest round.
GetLatestBlock(ctx context.Context) (*block.Block, error)
// GetRoundResults returns the round results for the given round.
GetRoundResults(ctx context.Context, round uint64) (*RoundResults, error)
}