-
Notifications
You must be signed in to change notification settings - Fork 7
/
types.go
79 lines (65 loc) · 2.25 KB
/
types.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package types
import (
"fmt"
"math/big"
)
// TODO: doc it all
type Account struct {
Identifier []byte `json:"identifier"`
Balance *big.Int `json:"balance"`
Nonce int64 `json:"nonce"`
}
type AccountStatus uint32
const (
AccountStatusLatest AccountStatus = iota
AccountStatusPending
)
// ChainInfo describes the current status of a Kwil blockchain.
type ChainInfo struct {
ChainID string `json:"chain_id"`
BlockHeight uint64 `json:"block_height"`
BlockHash string `json:"block_hash"`
}
type JoinRequest struct {
Candidate []byte `json:"candidate"` // pubkey of the candidate validator
Power int64 `json:"power"` // the requested power
ExpiresAt int64 `json:"expires_at"` // the block height at which the join request expires
Board [][]byte `json:"board"` // slice of pubkeys of all the eligible voting validators
Approved []bool `json:"approved"` // slice of bools indicating if the corresponding validator approved
}
type Validator struct {
PubKey []byte `json:"pubkey"`
Power int64 `json:"power"`
}
// ValidatorRemoveProposal is a proposal from an existing validator (remover) to
// remove a validator (the target) from the validator set.
type ValidatorRemoveProposal struct {
Target []byte `json:"target"` // pubkey of the validator to remove
Remover []byte `json:"remover"` // pubkey of the validator proposing the removal
}
// NodeInfo contains public information about a node.
// It can be used by clients to join as a peer.
type NodeInfo struct {
NodeID string `json:"node_id"`
PublicKey HexBytes `json:"pubkey"`
P2PListenAddress string `json:"p2p_listen_address"`
}
func (v *Validator) String() string {
return fmt.Sprintf("{pubkey = %x, power = %d}", v.PubKey, v.Power)
}
// DatasetIdentifier contains the information required to identify a dataset.
type DatasetIdentifier struct {
Name string `json:"name"`
Owner []byte `json:"owner"`
DBID string `json:"dbid"`
}
// VotableEvent is an event that can be voted.
// It contains an event type and a body.
// An ID can be generated from the event type and body.
type VotableEvent struct {
Type string `json:"type"`
Body []byte `json:"body"`
}
func (e *VotableEvent) ID() UUID {
return NewUUIDV5(append([]byte(e.Type), e.Body...))
}