-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
params.go
56 lines (46 loc) · 1.24 KB
/
params.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
package types
import (
"fmt"
"cosmossdk.io/math"
)
// DefaultParams returns default distribution parameters
func DefaultParams() Params {
return Params{
CommunityTax: math.LegacyNewDecWithPrec(2, 2), // 2%
BaseProposerReward: math.LegacyZeroDec(), // deprecated
BonusProposerReward: math.LegacyZeroDec(), // deprecated
WithdrawAddrEnabled: true,
}
}
// ValidateBasic performs basic validation on distribution parameters.
func (p Params) ValidateBasic() error {
if p.CommunityTax.IsNegative() || p.CommunityTax.GT(math.LegacyOneDec()) {
return fmt.Errorf(
"community tax should be non-negative and less than one: %s", p.CommunityTax,
)
}
return nil
}
func validateCommunityTax(i interface{}) error {
v, ok := i.(math.LegacyDec)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}
if v.IsNil() {
return fmt.Errorf("community tax must be not nil")
}
if v.IsNegative() {
return fmt.Errorf("community tax must be positive: %s", v)
}
if v.GT(math.LegacyOneDec()) {
return fmt.Errorf("community tax too large: %s", v)
}
return nil
}
func validateWithdrawAddrEnabled(i interface{}) error {
_, ok := i.(bool)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}
return nil
}