/
milestone.go
122 lines (97 loc) · 2.21 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
package types
import (
"github.com/furyaxyz/fuxchain/libs/system"
"strconv"
"sync"
)
// Disable followings after milestoneMercuryHeight
// 1. TransferToContractBlock
// 2. ChangeEvmDenomByProposal
// 3. BankTransferBlock
// 4. ibc
var (
milestoneEarthHeight int64
milestoneVenus4Height int64
// note: it stores the earlies height of the node,and it is used by cli
nodePruneHeight int64
once sync.Once
)
const (
MainNet = system.Chain + "-196"
TestNet = system.TestnetPrefix + "-195"
MILESTONE_EARTH = "earth"
MILESTONE_Venus4 = "venus4"
)
func init() {
once.Do(func() {})
}
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
}
func SetupMainNetEnvironment(pruneH int64) {
nodePruneHeight = pruneH
}
func SetupTestNetEnvironment(pruneH int64) {
nodePruneHeight = pruneH
}
// 2322600 is mainnet GenesisHeight
func IsMainNet() bool {
//return MILESTONE_GENESIS_HEIGHT == "2322600"
return false
}
// 1121818 is testnet GenesisHeight
func IsTestNet() bool {
//return MILESTONE_GENESIS_HEIGHT == "1121818"
return false
}
func GetStartBlockHeight() int64 {
return 0
}
func GetNodePruneHeight() int64 {
return nodePruneHeight
}
// ==================================
// =========== Earth ===============
func UnittestOnlySetMilestoneEarthHeight(h int64) {
milestoneEarthHeight = h
}
func SetMilestoneEarthHeight(h int64) {
milestoneEarthHeight = h
}
func HigherThanEarth(h int64) bool {
if milestoneEarthHeight == 0 {
return false
}
return h >= milestoneEarthHeight
}
func GetEarthHeight() int64 {
return milestoneEarthHeight
}
// =========== Earth ===============
// ==================================
// ==================================
// =========== Venus4 ===============
func HigherThanVenus4(h int64) bool {
if milestoneVenus4Height == 0 {
return false
}
return h > milestoneVenus4Height
}
func SetMilestoneVenus4Height(h int64) {
milestoneVenus4Height = h
}
func UnittestOnlySetMilestoneVenus4Height(h int64) {
milestoneVenus4Height = h
}
func GetVenus4Height() int64 {
return milestoneVenus4Height
}
// =========== Venus4 ===============
// ==================================