/
deposit.go
executable file
·199 lines (172 loc) · 6.36 KB
/
deposit.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
/*
This file is part of go-palletone.
go-palletone is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
go-palletone is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with go-palletone. If not, see <http://www.gnu.org/licenses/>.
*/
package modules
import (
"github.com/palletone/go-palletone/common"
"github.com/palletone/go-palletone/core"
"github.com/shopspring/decimal"
)
const (
ListForApplyBecomeMediator = "ListForApplyBecomeMediator"
ListForAgreeBecomeMediator = "ListForAgreeBecomeMediator"
ListForQuit = "ListForQuit"
ListForForfeiture = "ListForForfeiture"
JuryApplyQuit = "JuryApplyQuit"
DeveloperApplyQuit = "DeveloperApplyQuit"
Developer = "Developer"
Jury = "Jury"
Mediator = "Mediator"
Ok = "ok"
No = "no"
//获取候选列表
GetListForMediatorCandidate = "GetListForMediatorCandidate"
GetListForJuryCandidate = "GetListForJuryCandidate"
GetListForDeveloper = "GetListForDeveloper"
//查看是否在候选列表中
IsInMediatorCandidateList = "IsInMediatorCandidateList"
IsInJuryCandidateList = "IsInJuryCandidateList"
IsInDeveloperList = "IsInDeveloperList"
// 是否在相应列表中
IsInBecomeList = "IsInBecomeList"
//IsInAgressList = "IsInAgressList"
IsInQuitList = "IsInQuitList"
IsInForfeitureList = "IsInForfeitureList"
//获取列表
GetBecomeMediatorApplyList = "GetBecomeMediatorApplyList"
GetAgreeForBecomeMediatorList = "GetAgreeForBecomeMediatorList"
GetQuitApplyList = "GetQuitApplyList"
GetListForForfeitureApplication = "GetListForForfeitureApplication"
//申请
ApplyForForfeitureDeposit = "ApplyForForfeitureDeposit"
DeveloperPayToDepositContract = "DeveloperPayToDepositContract"
JuryPayToDepositContract = "JuryPayToDepositContract"
//基金会处理
HandleForForfeitureApplication = "HandleForForfeitureApplication"
HandleForApplyQuitMediator = "HandleForApplyQuitMediator"
HandleForApplyBecomeMediator = "HandleForApplyBecomeMediator"
HandleForApplyQuitJury = "HandleForApplyQuitJury"
HandleForApplyQuitDev = "HandleForApplyQuitDev"
HanldeNodeRemoveFromAgreeList = "HanldeNodeRemoveFromAgreeList"
GetDeposit = "GetNodeBalance"
GetJuryDeposit = "GetJuryDeposit"
// 质押相关
PledgeDeposit = "PledgeDeposit"
PledgeWithdraw = "PledgeWithdraw"
QueryPledgeStatusByAddr = "QueryPledgeStatusByAddr"
QueryAllPledgeHistory = "QueryAllPledgeHistory"
QueryPledgeHistoryByAddr = "QueryPledgeHistoryByAddr"
HandlePledgeReward = "HandlePledgeReward"
AllPledgeVotes = "allPledgeVotes"
QueryPledgeList = "QueryPledgeList"
QueryPledgeWithdraw = "QueryPledgeWithdraw"
QueryPledgeListByDate = "QueryPledgeListByDate"
// mediator状态
Apply = "Applying"
Agree = "Approved"
Quitting = "Quitting"
Quited = "Quited"
// 时间格式
// Layout1 = "2006-01-02 15"
// Layout2 = "2006-01-02 15:04"
// Layout3 = "2006-01-02 15:04:05"
// 目前使用 time.Now().UTC().Format(Layout) 返回字符串
Layout2 = "2006-01-02 15:04:05 MST"
HandleMediatorInCandidateList = "HandleMediatorInCandidateList"
HandleJuryInCandidateList = "HandleJuryInCandidateList"
HandleDevInList = "HandleDevInList"
GetAllMediator = "GetAllMediator"
GetAllNode = "GetAllNode"
GetAllJury = "GetAllJury"
UpdateJuryInfo = "UpdateJuryInfo"
)
//申请退出
type QuitNode struct {
Address string `json:"address"` //请求地址
Role string `json:"role"` //请求角色
Time string `json:"time"` //请求时间
}
//申请没收保证金
type Forfeiture struct {
ApplyAddress string `json:"apply_address"` //谁发起的
ForfeitureAddress string `json:"forfeiture_address"` //没收节点地址
ForfeitureRole string `json:"forfeiture_role"` //没收角色
Extra string `json:"extra"` //备注
ApplyTime string `json:"apply_time"` //请求时间
}
//交易的内容
type PayValue struct {
PayTokens *AmountAsset `json:"pay_tokens"` //数量和资产
PayTime string `json:"pay_time"` //发生时间
//PayExtra string `json:"pay_extra"` //额外内容
}
// 保证金信息
type DepositBalance struct {
Balance uint64 `json:"balance"` // 保证金余额
EnterTime string `json:"enter_time"` // 交保证金的时间
Role string `json:"role"` // 角色,包括mediator、jury和developer
}
// juror保证金信息
type JurorDeposit struct {
DepositBalance
core.JurorDepositExtra
Address string `json:"address"` // juror地址
}
func (jd *JurorDeposit) GetRewardAdd() common.Address {
if jd.RewardAddr != (common.Address{}) {
return jd.RewardAddr
} else {
add, _ := common.StringToAddress(jd.Address)
return add
}
}
// mediator保证金額外信息
type MediatorDepositExtra struct {
ApplyEnterTime string `json:"apply_enter_time"` // 申请加入时间
ApplyQuitTime string `json:"apply_quit_time"` // 申请退出时间
Status string `json:"status"` // 申请状态 申请、同意、退出
AgreeTime string `json:"agree_time"` // 基金会同意申请时间'
}
// mediator保证金信息
type MediatorDeposit struct {
MediatorDepositExtra
DepositBalance
}
func NewMediatorDeposit() *MediatorDeposit {
md := &MediatorDeposit{}
md.Status = Quited
return md
}
type NorNodBal struct {
AmountAsset *AmountAsset `json:"amount_asset"`
MediatorAddr string `json:"mediator_address"`
}
type Member struct {
Key string `json:"key"`
Value []byte `json:"value"`
}
type DepositBalanceJson struct {
Balance decimal.Decimal `json:"balance"`
EnterTime string `json:"enter_time"`
Role string `json:"role"`
}
type MediatorDepositJson struct {
MediatorDepositExtra
DepositBalanceJson
}
// juror保证金信息
type JuryDepositJson struct {
DepositBalanceJson
core.JurorDepositExtraJson
Address string `json:"address"`
}