-
Notifications
You must be signed in to change notification settings - Fork 1
/
staking.go
303 lines (266 loc) · 6.72 KB
/
staking.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
package types
type StakeRequirements struct {
Height int64
Role uint8
Requirement uint64
}
// Equal tells whether v and w represent the same rows
func (v StakeRequirements) Equal(w StakeRequirements) bool {
return v.Height == w.Height &&
v.Role == w.Role &&
v.Requirement == w.Requirement
}
// StakeRequirements allows to build a new StakeRequirements
func NewStakeRequirements(
height int64,
role uint8,
requirement uint64) StakeRequirements {
return StakeRequirements{
Height: height,
Role: role,
Requirement: requirement,
}
}
type TotalStakeByType struct {
Height int64
Role int8
TotalStake uint64
}
// Equal tells whether v and w represent the same rows
func (v TotalStakeByType) Equal(w TotalStakeByType) bool {
return v.Height == w.Height &&
v.Role == w.Role &&
v.TotalStake == w.TotalStake
}
// TotalStake allows to build a new TotalStake
func NewTotalStakeByType(
height int64,
role int8,
totalStake uint64) TotalStakeByType {
return TotalStakeByType{
Height: height,
Role: role,
TotalStake: totalStake,
}
}
type WeeklyPayout struct {
Height int64
Payout uint64
}
// Equal tells whether v and w represent the same rows
func (v WeeklyPayout) Equal(w WeeklyPayout) bool {
return v.Height == w.Height &&
v.Payout == w.Payout
}
// WeeklyPayout allows to build a new WeeklyPayout
func NewWeeklyPayout(
height int64,
payout uint64) WeeklyPayout {
return WeeklyPayout{
Height: height,
Payout: payout,
}
}
type TotalStake struct {
Height int64
TotalStake uint64
}
// Equal tells whether v and w represent the same rows
func (v TotalStake) Equal(w TotalStake) bool {
return v.Height == w.Height &&
v.TotalStake == w.TotalStake
}
// TotalStake allows to build a new TotalStake
func NewTotalStake(
height int64,
totalStake uint64) TotalStake {
return TotalStake{
Height: height,
TotalStake: totalStake,
}
}
type StakingTable struct {
Height int64
StakingTable []string
}
// StakingTable allows to build a new StakingTable
func NewStakingTable(
height int64,
stakingTable []string) StakingTable {
return StakingTable{
Height: height,
StakingTable: stakingTable,
}
}
type ProposedTable struct {
Height int64
ProposedTable []string
}
// ProposedTable allows to build a new ProposedTable
func NewProposedTable(
height int64,
proposedTable []string) ProposedTable {
return ProposedTable{
Height: height,
ProposedTable: proposedTable,
}
}
type CurrentTable struct {
Height int64
Table []string
}
// CurrentTable allows to build a new CurrentTable
func NewCurrentTable(
height int64,
table []string) CurrentTable {
return CurrentTable{
Height: height,
Table: table,
}
}
type NodeUnstakingTokens struct {
NodeId string
TokenUnstaking uint64
Height int64
}
// Equal tells whether v and w represent the same rows
func (v NodeUnstakingTokens) Equal(w NodeUnstakingTokens) bool {
return v.NodeId == w.NodeId &&
v.TokenUnstaking == w.TokenUnstaking &&
v.Height == w.Height
}
// NodeUnstakingTokens allows to build a new NodeUnstakingTokens
func NewNodeUnstakingTokens(
nodeId string,
tokenUnstaking uint64,
height int64) NodeUnstakingTokens {
return NodeUnstakingTokens{
NodeId: nodeId,
TokenUnstaking: tokenUnstaking,
Height: height,
}
}
type NodeTotalCommitment struct {
NodeId string
TotalCommitment uint64
Height int64
}
// Equal tells whether v and w represent the same rows
func (v NodeTotalCommitment) Equal(w NodeTotalCommitment) bool {
return v.NodeId == w.NodeId &&
v.TotalCommitment == w.TotalCommitment &&
v.Height == w.Height
}
// NodeTotalCommitment allows to build a new NodeTotalCommitment
func NewNodeTotalCommitment(
nodeId string,
totalCommitment uint64,
height int64) NodeTotalCommitment {
return NodeTotalCommitment{
NodeId: nodeId,
TotalCommitment: totalCommitment,
Height: height,
}
}
type NodeTotalCommitmentWithoutDelegators struct {
NodeId string
TotalCommitmentWithoutDelegators uint64
Height int64
}
// Equal tells whether v and w represent the same rows
func (v NodeTotalCommitmentWithoutDelegators) Equal(w NodeTotalCommitmentWithoutDelegators) bool {
return v.NodeId == w.NodeId &&
v.TotalCommitmentWithoutDelegators == w.TotalCommitmentWithoutDelegators &&
v.Height == w.Height
}
// NodeTotalCommitmentWithoutDelegators allows to build a new NodeTotalCommitmentWithoutDelegators
func NewNodeTotalCommitmentWithoutDelegators(
nodeId string,
totalCommitmentWithoutDelegators uint64,
height int64) NodeTotalCommitmentWithoutDelegators {
return NodeTotalCommitmentWithoutDelegators{
NodeId: nodeId,
TotalCommitmentWithoutDelegators: totalCommitmentWithoutDelegators,
Height: height,
}
}
type NodeInfoFromAddress struct {
Address string
NodeInfo StakerNodeInfo
Height int64
}
// NodeInfoFromNodeIDs allows to build a new NodeInfoFromNodeIDs
func NewNodeInfoFromAddress(
address string,
nodeInfo StakerNodeInfo,
height int64) NodeInfoFromAddress {
return NodeInfoFromAddress{
Address: address,
NodeInfo: nodeInfo,
Height: height,
}
}
type NodeCommittedTokens struct {
NodeId string
CommittedTokens uint64
Height int64
}
// NodeCommittedTokens allows to build a new NodeCommittedTokens
func NewNodeCommittedTokens(
nodeId string,
committedTokens uint64,
height int64) NodeCommittedTokens {
return NodeCommittedTokens{
NodeId: nodeId,
CommittedTokens: committedTokens,
Height: height,
}
}
type CutPercentage struct {
CutPercentage uint64
Height int64
}
// CutPercentage allows to build a new CutPercentage
func NewCutPercentage(
cutPercentage uint64,
height int64) CutPercentage {
return CutPercentage{
CutPercentage: cutPercentage,
Height: height,
}
}
type DelegatorInfo struct {
DelegatorInfo DelegatorNodeInfo
Height uint64
NodeId string
DelegatorID uint32
}
// DelegatorInfo allows to build a new DelegatorInfo
func NewDelegatorInfo(
delegatorInfo DelegatorNodeInfo,
height uint64,
nodeId string,
delegatorID uint32) DelegatorInfo {
return DelegatorInfo{
DelegatorInfo: delegatorInfo,
Height: height,
NodeId: nodeId,
DelegatorID: delegatorID,
}
}
type DelegatorInfoFromAddress struct {
DelegatorInfo DelegatorNodeInfo
Height int64
Address string
}
// DelegatorInfoFromAddress allows to build a new DelegatorInfoFromAddress
func NewDelegatorInfoFromAddress(
delegatorInfo DelegatorNodeInfo,
height int64,
address string) DelegatorInfoFromAddress {
return DelegatorInfoFromAddress{
DelegatorInfo: delegatorInfo,
Height: height,
Address: address,
}
}