/
economicsHandler.go
executable file
·129 lines (105 loc) · 2.82 KB
/
economicsHandler.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 block
import (
"math/big"
"github.com/ThotaGopichandThota/gn-core/data"
)
// SetTotalSupply sets the total supply
func (e *Economics) SetTotalSupply(totalSupply *big.Int) error {
if e == nil {
return data.ErrNilPointerReceiver
}
if totalSupply == nil {
return data.ErrInvalidValue
}
if e.TotalSupply == nil {
e.TotalSupply = big.NewInt(0)
}
e.TotalSupply.Set(totalSupply)
return nil
}
// SetTotalToDistribute sets the total to be distributed
func (e *Economics) SetTotalToDistribute(totalToDistribute *big.Int) error {
if e == nil {
return data.ErrNilPointerReceiver
}
if totalToDistribute == nil {
return data.ErrInvalidValue
}
if e.TotalToDistribute == nil {
e.TotalToDistribute = big.NewInt(0)
}
e.TotalToDistribute.Set(totalToDistribute)
return nil
}
// SetTotalNewlyMinted sets the total number of minted tokens
func (e *Economics) SetTotalNewlyMinted(totalNewlyMinted *big.Int) error {
if e == nil {
return data.ErrNilPointerReceiver
}
if totalNewlyMinted == nil {
return data.ErrInvalidValue
}
if e.TotalNewlyMinted == nil {
e.TotalNewlyMinted = big.NewInt(0)
}
e.TotalNewlyMinted.Set(totalNewlyMinted)
return nil
}
// SetRewardsPerBlock sets the rewards per block
func (e *Economics) SetRewardsPerBlock(rewardsPerBlock *big.Int) error {
if e == nil {
return data.ErrNilPointerReceiver
}
if rewardsPerBlock == nil {
return data.ErrInvalidValue
}
if e.RewardsPerBlock == nil {
e.RewardsPerBlock = big.NewInt(0)
}
e.RewardsPerBlock.Set(rewardsPerBlock)
return nil
}
// SetRewardsForProtocolSustainability sets the rewards for protocol sustainability
func (e *Economics) SetRewardsForProtocolSustainability(rewardsForProtocolSustainability *big.Int) error {
if e == nil {
return data.ErrNilPointerReceiver
}
if rewardsForProtocolSustainability == nil {
return data.ErrInvalidValue
}
if e.RewardsForProtocolSustainability == nil {
e.RewardsForProtocolSustainability = big.NewInt(0)
}
e.RewardsForProtocolSustainability.Set(rewardsForProtocolSustainability)
return nil
}
// SetNodePrice sets the node price
func (e *Economics) SetNodePrice(nodePrice *big.Int) error {
if e == nil {
return data.ErrNilPointerReceiver
}
if nodePrice == nil {
return data.ErrInvalidValue
}
if e.NodePrice == nil {
e.NodePrice = big.NewInt(0)
}
e.NodePrice.Set(nodePrice)
return nil
}
// SetPrevEpochStartRound sets the previous epoch start round
func (e *Economics) SetPrevEpochStartRound(prevEpochStartRound uint64) error {
if e == nil {
return data.ErrNilPointerReceiver
}
e.PrevEpochStartRound = prevEpochStartRound
return nil
}
// SetPrevEpochStartHash sets the previous epoch start hash
func (e *Economics) SetPrevEpochStartHash(prevEpochStartHash []byte) error {
if e == nil {
return data.ErrNilPointerReceiver
}
e.PrevEpochStartHash = prevEpochStartHash
return nil
}