-
Notifications
You must be signed in to change notification settings - Fork 199
/
economicsDataHandlerStub.go
233 lines (200 loc) · 6.56 KB
/
economicsDataHandlerStub.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
package economicsmocks
import (
"math/big"
"github.com/ElrondNetwork/elrond-go/process"
)
// EconomicsHandlerStub -
type EconomicsHandlerStub struct {
MaxGasLimitPerBlockCalled func() uint64
ComputeGasLimitCalled func(tx process.TransactionWithFeeHandler) uint64
ComputeMoveBalanceFeeCalled func(tx process.TransactionWithFeeHandler) *big.Int
ComputeTxFeeCalled func(tx process.TransactionWithFeeHandler) *big.Int
CheckValidityTxValuesCalled func(tx process.TransactionWithFeeHandler) error
DeveloperPercentageCalled func() float64
MinGasPriceCalled func() uint64
GasPriceModifierCalled func() float64
LeaderPercentageCalled func() float64
ProtocolSustainabilityPercentageCalled func() float64
ProtocolSustainabilityAddressCalled func() string
MinInflationRateCalled func() float64
MaxInflationRateCalled func(year uint32) float64
GasPerDataByteCalled func() uint64
MinGasLimitCalled func() uint64
GenesisTotalSupplyCalled func() *big.Int
ComputeFeeForProcessingCalled func(tx process.TransactionWithFeeHandler, gasToUse uint64) *big.Int
RewardsTopUpGradientPointCalled func() *big.Int
RewardsTopUpFactorCalled func() float64
SplitTxGasInCategoriesCalled func(tx process.TransactionWithFeeHandler) (uint64, uint64)
GasPriceForProcessingCalled func(tx process.TransactionWithFeeHandler) uint64
GasPriceForMoveCalled func(tx process.TransactionWithFeeHandler) uint64
MinGasPriceProcessingCalled func() uint64
}
// ComputeFeeForProcessing -
func (e *EconomicsHandlerStub) ComputeFeeForProcessing(tx process.TransactionWithFeeHandler, gasToUse uint64) *big.Int {
if e.ComputeFeeForProcessingCalled != nil {
return e.ComputeFeeForProcessingCalled(tx, gasToUse)
}
return big.NewInt(0)
}
// LeaderPercentage -
func (e *EconomicsHandlerStub) LeaderPercentage() float64 {
if e.LeaderPercentageCalled != nil {
return e.LeaderPercentageCalled()
}
return 0.0
}
// ProtocolSustainabilityPercentage -
func (e *EconomicsHandlerStub) ProtocolSustainabilityPercentage() float64 {
if e.ProtocolSustainabilityAddressCalled != nil {
return e.ProtocolSustainabilityPercentageCalled()
}
return 0.0
}
// ProtocolSustainabilityAddress -
func (e *EconomicsHandlerStub) ProtocolSustainabilityAddress() string {
if e.ProtocolSustainabilityAddressCalled != nil {
return e.ProtocolSustainabilityAddressCalled()
}
return ""
}
// MinInflationRate -
func (e *EconomicsHandlerStub) MinInflationRate() float64 {
if e.MinInflationRateCalled != nil {
return e.MinInflationRateCalled()
}
return 0.0
}
// MaxInflationRate -
func (e *EconomicsHandlerStub) MaxInflationRate(year uint32) float64 {
if e.MaxInflationRateCalled != nil {
return e.MaxInflationRateCalled(year)
}
return 0.0
}
// GasPerDataByte -
func (e *EconomicsHandlerStub) GasPerDataByte() uint64 {
if e.GasPerDataByteCalled != nil {
return e.GasPerDataByteCalled()
}
return 0
}
// MinGasLimit -
func (e *EconomicsHandlerStub) MinGasLimit() uint64 {
if e.MinGasLimitCalled != nil {
return e.MinGasLimitCalled()
}
return 0
}
// GenesisTotalSupply -
func (e *EconomicsHandlerStub) GenesisTotalSupply() *big.Int {
if e.GenesisTotalSupplyCalled != nil {
return e.GenesisTotalSupplyCalled()
}
return big.NewInt(100000000)
}
// GasPriceModifier -
func (e *EconomicsHandlerStub) GasPriceModifier() float64 {
if e.GasPriceModifierCalled != nil {
return e.GasPriceModifierCalled()
}
return 1.0
}
// MinGasPrice -
func (e *EconomicsHandlerStub) MinGasPrice() uint64 {
if e.MinGasPriceCalled != nil {
return e.MinGasPriceCalled()
}
return 0
}
// DeveloperPercentage -
func (e *EconomicsHandlerStub) DeveloperPercentage() float64 {
if e.DeveloperPercentageCalled != nil {
return e.DeveloperPercentageCalled()
}
return 0.0
}
// MaxGasLimitPerBlock -
func (e *EconomicsHandlerStub) MaxGasLimitPerBlock(uint32) uint64 {
if e.MaxGasLimitPerBlockCalled != nil {
return e.MaxGasLimitPerBlockCalled()
}
return 1000000
}
// ComputeGasLimit -
func (e *EconomicsHandlerStub) ComputeGasLimit(tx process.TransactionWithFeeHandler) uint64 {
if e.ComputeGasLimitCalled != nil {
return e.ComputeGasLimitCalled(tx)
}
return 0
}
// ComputeMoveBalanceFee -
func (e *EconomicsHandlerStub) ComputeMoveBalanceFee(tx process.TransactionWithFeeHandler) *big.Int {
if e.ComputeMoveBalanceFeeCalled != nil {
return e.ComputeMoveBalanceFeeCalled(tx)
}
return big.NewInt(0)
}
// ComputeTxFee -
func (e *EconomicsHandlerStub) ComputeTxFee(tx process.TransactionWithFeeHandler) *big.Int {
if e.ComputeTxFeeCalled != nil {
return e.ComputeTxFeeCalled(tx)
}
return big.NewInt(0)
}
// CheckValidityTxValues -
func (e *EconomicsHandlerStub) CheckValidityTxValues(tx process.TransactionWithFeeHandler) error {
if e.CheckValidityTxValuesCalled != nil {
return e.CheckValidityTxValuesCalled(tx)
}
return nil
}
// RewardsTopUpGradientPoint -
func (e *EconomicsHandlerStub) RewardsTopUpGradientPoint() *big.Int {
if e.RewardsTopUpGradientPointCalled != nil {
return e.RewardsTopUpGradientPointCalled()
}
return big.NewInt(0)
}
// RewardsTopUpFactor -
func (e *EconomicsHandlerStub) RewardsTopUpFactor() float64 {
if e.RewardsTopUpFactorCalled != nil {
return e.RewardsTopUpFactorCalled()
}
return 0
}
// SplitTxGasInCategories -
func (e *EconomicsHandlerStub) SplitTxGasInCategories(tx process.TransactionWithFeeHandler) (uint64, uint64) {
if e.SplitTxGasInCategoriesCalled != nil {
return e.SplitTxGasInCategoriesCalled(tx)
}
processingGas := uint64(0)
if e.ComputeGasLimit(tx) > e.MinGasLimit() {
processingGas = e.ComputeGasLimit(tx) - e.MinGasLimit()
}
return e.MinGasLimit(), processingGas
}
// GasPriceForProcessing -
func (e *EconomicsHandlerStub) GasPriceForProcessing(tx process.TransactionWithFeeHandler) uint64 {
if e.GasPriceForProcessingCalled != nil {
return e.GasPriceForProcessingCalled(tx)
}
return 1
}
// GasPriceForMove -
func (e *EconomicsHandlerStub) GasPriceForMove(tx process.TransactionWithFeeHandler) uint64 {
if e.GasPriceForMoveCalled != nil {
return e.GasPriceForMoveCalled(tx)
}
return 100
}
// MinGasPriceProcessing -
func (e *EconomicsHandlerStub) MinGasPriceForProcessing() uint64 {
if e.MinGasPriceProcessingCalled != nil {
return e.MinGasPriceProcessingCalled()
}
return 1
}
// IsInterfaceNil returns true if there is no value under the interface
func (e *EconomicsHandlerStub) IsInterfaceNil() bool {
return e == nil
}