-
Notifications
You must be signed in to change notification settings - Fork 0
/
elrond.go
129 lines (118 loc) · 3.09 KB
/
elrond.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
package types
import (
"time"
)
// Validator contains the data of a single validator
type Validator struct {
ConsAddr string
ConsPubKey string
}
// NewValidator allows to build a new Validator instance
func NewValidator(consAddr string, consPubKey string) *Validator {
return &Validator{
ConsAddr: consAddr,
ConsPubKey: consPubKey,
}
}
// -------------------------------------------------------------------------------------------------------------------
// CommitSig contains the data of a single validator commit signature
type CommitSig struct {
Height int64
ValidatorAddress string
VotingPower int64
ProposerPriority int64
Timestamp time.Time
}
// NewCommitSig allows to build a new CommitSign object
func NewCommitSig(validatorAddress string, votingPower, proposerPriority, height int64, timestamp time.Time) *CommitSig {
return &CommitSig{
Height: height,
ValidatorAddress: validatorAddress,
VotingPower: votingPower,
ProposerPriority: proposerPriority,
Timestamp: timestamp,
}
}
// -------------------------------------------------------------------------------------------------------------------
// Block contains the data of a single chain block
type Block struct {
Hash string
Epoch int64
Nonce int64
PrevHash string
Proposer int64
PubKeyBitmap string
Round int64
Shard int64
Size int64
SizeTxs int64
StateRootHash string
TimeStamp int64
TxCount int64
GasConsumed int64
GasRefunded int64
GasPenalized int64
MaxGasLimit int64
MiniBlocksHashes []string
Validators []int64
NotarizedBlocksHashes []string
}
// Equal tells whether v and w represent the same rows
func (v Block) Equal(w Block) bool {
return v.Hash == w.Hash &&
v.Epoch == w.Epoch &&
v.Nonce == w.Nonce &&
v.PrevHash == w.PrevHash &&
v.Proposer == w.Proposer &&
v.PubKeyBitmap == w.PubKeyBitmap &&
v.Round == w.Round &&
v.Shard == w.Shard &&
v.Size == w.Size &&
v.SizeTxs == w.SizeTxs &&
v.StateRootHash == w.StateRootHash &&
v.TimeStamp == w.TimeStamp &&
v.TxCount == w.TxCount &&
v.GasConsumed == w.GasConsumed &&
v.GasRefunded == w.GasRefunded &&
v.GasPenalized == w.GasPenalized &&
v.MaxGasLimit == w.MaxGasLimit
}
// Block allows to build a new Block
func NewBlock(
hash string,
epoch int64,
nonce int64,
prevHash string,
proposer int64,
pubKeyBitmap string,
round int64,
shard int64,
size int64,
sizeTxs int64,
stateRootHash string,
timeStamp int64,
txCount int64,
gasConsumed int64,
gasRefunded int64,
gasPenalized int64,
maxGasLimit int64) Block {
return Block{
Hash: hash,
Epoch: epoch,
Nonce: nonce,
PrevHash: prevHash,
Proposer: proposer,
PubKeyBitmap: pubKeyBitmap,
Round: round,
Shard: shard,
Size: size,
SizeTxs: sizeTxs,
StateRootHash: stateRootHash,
TimeStamp: timeStamp,
TxCount: txCount,
GasConsumed: gasConsumed,
GasRefunded: gasRefunded,
GasPenalized: gasPenalized,
MaxGasLimit: maxGasLimit,
}
}