-
Notifications
You must be signed in to change notification settings - Fork 107
/
light.go
61 lines (50 loc) · 2.42 KB
/
light.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
51
52
53
54
55
56
57
58
59
60
61
package api
import (
"context"
"github.com/oasisprotocol/oasis-core/go/consensus/api/transaction"
"github.com/oasisprotocol/oasis-core/go/consensus/genesis"
"github.com/oasisprotocol/oasis-core/go/storage/mkvs/syncer"
)
// LightClientBackend is the limited consensus interface used by light clients.
type LightClientBackend interface {
// GetLightBlock returns a light version of the consensus layer block that can be used for light
// client verification.
GetLightBlock(ctx context.Context, height int64) (*LightBlock, error)
// GetLightBlockForState returns a light block for the state as of executing the consensus layer
// block at the specified height. Note that the height of the returned block may differ
// depending on consensus layer implementation details.
//
// In case light block for the given height is not yet available, it returns ErrVersionNotFound.
GetLightBlockForState(ctx context.Context, height int64) (*LightBlock, error)
// GetParameters returns the consensus parameters for a specific height.
GetParameters(ctx context.Context, height int64) (*Parameters, error)
// State returns a MKVS read syncer that can be used to read consensus state from a remote node
// and verify it against the trusted local root.
State() syncer.ReadSyncer
// SubmitTxNoWait submits a signed consensus transaction, but does not wait for the transaction
// to be included in a block. Use SubmitTx if you need to wait for execution.
SubmitTxNoWait(ctx context.Context, tx *transaction.SignedTransaction) error
// SubmitEvidence submits evidence of misbehavior.
SubmitEvidence(ctx context.Context, evidence *Evidence) error
}
// LightBlock is a light consensus block suitable for syncing light clients.
type LightBlock struct {
// Height contains the block height.
Height int64 `json:"height"`
// Meta contains the consensus backend specific light block.
Meta []byte `json:"meta"`
}
// Parameters are the consensus backend parameters.
type Parameters struct {
// Height contains the block height these consensus parameters are for.
Height int64 `json:"height"`
// Parameters are the backend agnostic consensus parameters.
Parameters genesis.Parameters `json:"parameters"`
// Meta contains the consensus backend specific consensus parameters.
Meta []byte `json:"meta"`
}
// Evidence is evidence of a node's Byzantine behavior.
type Evidence struct {
// Meta contains the consensus backend specific evidence.
Meta []byte `json:"meta"`
}