-
Notifications
You must be signed in to change notification settings - Fork 25
/
block_export_data.go
48 lines (37 loc) · 1.55 KB
/
block_export_data.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
package data
import (
sdk "github.com/algorand/go-algorand-sdk/v2/types"
"github.com/algorand/conduit/conduit/telemetry"
)
// RoundProvider is the interface which all data types sent to Exporters should implement
type RoundProvider interface {
Round() uint64
Empty() bool
}
// InitProvider is the interface that can be used when initializing to get common algod related
// variables
type InitProvider interface {
GetGenesis() *sdk.Genesis
SetGenesis(*sdk.Genesis)
NextDBRound() sdk.Round
GetTelemetryClient() telemetry.Client
}
// BlockData is provided to the Exporter on each round.
type BlockData struct {
// BlockHeader is the immutable header from the block
BlockHeader sdk.BlockHeader `json:"block,omitempty"`
// Payset is the set of data the block is carrying--can be modified as it is processed
Payset []sdk.SignedTxnInBlock `json:"payset,omitempty"`
// Delta contains a list of account changes resulting from the block. Processor plugins may have modify this data.
Delta *sdk.LedgerStateDelta `json:"delta,omitempty"`
// Certificate contains voting data that certifies the block. The certificate is non deterministic, a node stops collecting votes once the voting threshold is reached.
Certificate *map[string]interface{} `json:"cert,omitempty"`
}
// Round returns the round to which the BlockData corresponds
func (blkData BlockData) Round() uint64 {
return uint64(blkData.BlockHeader.Round)
}
// Empty returns whether the Block contains Txns. Assumes the Block is never nil
func (blkData BlockData) Empty() bool {
return len(blkData.Payset) == 0
}