-
Notifications
You must be signed in to change notification settings - Fork 182
/
milestone.go
137 lines (111 loc) · 2.79 KB
/
milestone.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
package types
import (
"strconv"
"sync"
)
// Disable followings after milestoneMercuryHeight
// 1. TransferToContractBlock
// 2. ChangeEvmDenomByProposal
// 3. BankTransferBlock
// 4. ibc
var (
MILESTONE_GENESIS_HEIGHT string
genesisHeight int64
MILESTONE_MERCURY_HEIGHT string
milestoneMercuryHeight int64
MILESTONE_VENUS_HEIGHT string
milestoneVenusHeight int64
MILESTONE_MARS_HEIGHT string
milestoneMarsHeight int64
MILESTONE_VENUS1_HEIGHT string
milestoneVenus1Height int64
once sync.Once
)
func init() {
once.Do(func() {
genesisHeight = string2number(MILESTONE_GENESIS_HEIGHT)
milestoneMercuryHeight = string2number(MILESTONE_MERCURY_HEIGHT)
milestoneVenusHeight = string2number(MILESTONE_VENUS_HEIGHT)
milestoneMarsHeight = string2number(MILESTONE_MARS_HEIGHT)
milestoneVenus1Height = string2number(MILESTONE_VENUS1_HEIGHT)
})
}
func string2number(input string) int64 {
if len(input) == 0 {
input = "0"
}
res, err := strconv.ParseInt(input, 10, 64)
if err != nil {
panic(err)
}
return res
}
//depracate homstead signer support
func HigherThanMercury(height int64) bool {
if milestoneMercuryHeight == 0 {
// milestoneMercuryHeight not enabled
return false
}
return height > milestoneMercuryHeight
}
func HigherThanVenus(height int64) bool {
if milestoneVenusHeight == 0 {
return false
}
return height >= milestoneVenusHeight
}
//use MPT storage model to replace IAVL storage model
func HigherThanMars(height int64) bool {
if milestoneMarsHeight == 0 {
return false
}
return height > milestoneMarsHeight
}
// GetMilestoneVenusHeight returns milestoneVenusHeight
func GetMilestoneVenusHeight() int64 {
return milestoneVenusHeight
}
// 2322600 is mainnet GenesisHeight
func IsMainNet() bool {
return MILESTONE_GENESIS_HEIGHT == "2322600"
}
// 1121818 is testnet GenesisHeight
func IsTestNet() bool {
return MILESTONE_GENESIS_HEIGHT == "1121818"
}
func GetStartBlockHeight() int64 {
return genesisHeight
}
func GetVenusHeight() int64 {
return milestoneVenusHeight
}
func GetMercuryHeight() int64 {
return milestoneMercuryHeight
}
func GetMarsHeight() int64 {
return milestoneMarsHeight
}
// can be used in unit test only
func UnittestOnlySetMilestoneVenusHeight(height int64) {
milestoneVenusHeight = height
}
// can be used in unit test only
func UnittestOnlySetMilestoneMarsHeight(height int64) {
milestoneMarsHeight = height
}
// ==================================
// =========== Venus1 ===============
func HigherThanVenus1(h int64) bool {
if milestoneVenus1Height == 0 {
return false
}
return h >= milestoneVenus1Height
}
func UnittestOnlySetMilestoneVenus1Height(h int64) {
milestoneVenus1Height = h
}
func GetVenus1Height() int64 {
return milestoneVenus1Height
}
// =========== Venus1 ===============
// ==================================