This repository has been archived by the owner on Nov 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
metahash.go
executable file
·309 lines (277 loc) · 9.69 KB
/
metahash.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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
package metahash
type BalanceArgs struct {
Address string `json:"address"`
}
type BalancesArgs struct {
Addresses []string `json:"addresses"`
}
type Balance struct {
Address string `json:"address"`
Received int64 `json:"received"`
Spent int64 `json:"spent"`
CountReceived int64 `json:"count_received"`
CountSpent int64 `json:"count_spent"`
CountTxs int64 `json:"count_txs"`
BlockNumber int64 `json:"block_number"`
CurrentBlock int64 `json:"currentBlock"`
Hash string `json:"hash"`
CountDelegatedOps int64 `json:"countDelegatedOps"`
Delegate int64 `json:"delegate"`
Undelegate int64 `json:"undelegate"`
Delegated int64 `json:"delegated"`
Undelegated int64 `json:"undelegated"`
Reserved int64 `json:"reserved"`
CountForgedOps int64 `json:"countForgedOps"`
Forged int64 `json:"forged"`
}
type TransactionArgs struct {
Hash string `json:"hash"`
}
type Transaction struct {
Transaction TransactionInfo `json:"transaction"`
CountBlocks int64 `json:"countBlocks"`
KnownBlocks int64 `json:"knownBlocks"`
}
type HistoryFilter struct {
IsInput bool `json:"isInput,omitempty"` // isInput - Display only isInput transactions
IsOutput bool `json:"isOutput,omitempty"` //isOutput - Display only isOutput transactions
IsSuccess bool `json:"isSuccess,omitempty"` //isSuccess - Display only success transactions
IsForging bool `json:"isForging,omitempty"` //isForging - Display only forging transactions
IsTest bool `json:"isTest,omitempty"` //isTest - Display only test transactions
IsDelegate bool `json:"isDelegate,omitempty"` //isDelegate - Display only delegation transactions
}
type HistoryArgs struct {
Address string `json:"address"`
BeginTx int64 `json:"beginTx,omitempty"`
CountTxs int64 `json:"countTxs,omitempty"`
Filters HistoryFilter `json:"filters,omitempty"`
}
type BlockByNumberArgs struct {
Number int64 `json:"number"`
BeginTx int64 `json:"beginTx,omitempty"`
CountTxs int64 `json:"countTxs,omitempty"`
Type int8 `json:"type,omitempty"` // 0-4
// 0 - простой тип с 7 подписями
// 1 - 7 подписей и массив хешей всех транзакций
// 2 - 7 подписей и все транзакции полностью
// 3 - краткий формат блока, только прошлый и текущий хеш
// 4 - краткий формат 3 + размер блока и расположение файла данных
}
type BlockByHashArgs struct {
Hash string `json:"hash"`
BeginTx int64 `json:"beginTx,omitempty"`
CountTxs int64 `json:"countTxs,omitempty"`
Type int8 `json:"type,omitempty"` // 0-4
}
type BlocksArgs struct {
CountBlocks int64 `json:"countBlocks,omitempty"`
BeginBlock int64 `json:"beginBlock,omitempty"`
}
type Block struct {
Type string `json:"type"`
Hash string `json:"hash"`
PrevHash string `json:"prev_hash"`
TxHash string `json:"tx_hash"`
Number int64 `json:"number"`
TimeStamp int64 `json:"timestamp"`
CountTxs int64 `json:"count_txs"`
Sign string `json:"sign"`
Size int64 `json:"size"`
FileName string `json:"fileName"`
Signatures []struct {
From string `json:"from"`
To string `json:"to"`
Value int64 `json:"value"`
Transaction string `json:"transaction"`
Data string `json:"data"`
TimeStamp int64 `json:"timestamp"`
Type string `json:"type"`
BlockNumber int64 `json:"blockNumber"`
Signature string `json:"signature"`
Publickey string `json:"publickey"`
Fee int64 `json:"fee"`
RealFee int64 `json:"realFee"`
Nonce int64 `json:"nonce"`
IntStatus int64 `json:"intStatus"`
Status string `json:"status"`
} `json:"signatures,omitempty"`
Txs []*TransactionInfo `json:"txs"`
}
type LastTxsArgs struct {
}
type TransactionInfo struct {
From string `json:"from" db:"fromA"`
To string `json:"to" db:"toA"`
Value int64 `json:"value"`
Transaction string `json:"transaction"`
Data string `json:"data"`
TimeStamp int64 `json:"timestamp" db:"timestamp,int64"`
Type string `json:"type" db:"typeTx"`
BlockNumber int64 `json:"blockNumber" db:"blockNumber"`
Signature string `json:"signature"`
PublicKey string `json:"publickey"`
Fee int64 `json:"fee"`
RealFee int64 `json:"realFee" db:"realFee"`
Nonce int64 `json:"nonce"`
IntStatus int64 `json:"intStatus" db:"intStatus"`
Status string `json:"status"`
IsDelegate bool `json:"isDelegate,omitempty" db:"isDelegate"`
DelegateInfo struct {
IsDelegate bool `json:"isDelegate"`
Delegate int64 `json:"delegate,omitempty"`
DelegateHash string `json:"delegateHash,omitempty"`
} `json:"delegate_info,omitempty" db:"-"`
Delegate int64 `json:"delegate,omitempty"`
DelegateHash string `json:"delegateHash,omitempty" db:"delegateHash"`
}
type DumpBlockByNumberArgs struct {
Number int64 `json:"number"`
IsHex bool `json:"isHex,omitempty"`
}
type DumpBlockByHashArgs struct {
Hash string `json:"hash"`
IsHex bool `json:"isHex,omitempty"`
}
type DumpBlock struct {
Dump string `json:"dump"`
}
type CountBlocksArgs struct {
}
type CountBlocks struct {
CountBlocks int64 `json:"count_blocks"`
BeginBlock int64 `json:"beginBlock"`
}
// внутренние структуры-методы
type NodeRegistration struct {
Jsonrpc string `json:"jsonrpc"`
Method string `json:"method"`
Params struct {
Host string `json:"host"`
Name string `json:"name"`
Type string `json:"type,omitempty"`
} `json:"params"`
}
type AbstractMethod struct {
Jsonrpc string `json:"jsonrpc"`
Method string `json:"method"`
Params interface{} `json:"params,omitempty"`
}
type NodeArgs struct {
Address string `json:"address"`
BeginTx int64 `json:"beginTx,omitempty"`
CountTxs int64 `json:"countTxs,omitempty"`
CountTests int `json:"count_tests,omitempty"`
}
type NodeTest struct {
TimeStamp int64 `json:"timestamp"`
Method string `json:"method"`
Params struct {
Mhaddr string `json:"mhaddr"`
IP string `json:"ip"`
QPS int64 `json:"qps"`
Rps int64 `json:"rps"`
Closed string `json:"closed"`
Timeouts string `json:"timeouts"`
Ver string `json:"ver"`
Success string `json:"success"`
} `json:"params"`
}
type NodeStats struct {
Address string `json:"address"`
Type string `json:"type"`
AvgRps string `json:"avgRps"`
IsLatency bool `json:"isLatency"`
IP string `json:"ip"`
Geo string `json:"geo"`
State string `json:"state"`
Timestamp int `json:"timestamp"`
Success bool `json:"success"`
LastBlockTimestamp int `json:"lastBlockTimestamp"`
}
type NodeStatsState struct {
ID string `json:"id"`
Jsonrpc string `json:"jsonrpc"`
Method string `json:"method"`
Params struct {
Type string `json:"type"`
Ver string `json:"ver"`
Address string `json:"address"`
Host string `json:"host"`
Blockheightcheck string `json:"blockHeightCheck"`
Requestsperminute string `json:"requestsPerMinute"`
Latency string `json:"latency"`
Geo string `json:"geo"`
Success string `json:"success"`
} `json:"params"`
}
type NodeTrust struct {
Address string `json:"address"`
Trust int64 `json:"trust"`
Data string `json:"data"`
Timestamp int64 `json:"timestamp"`
Lastblocktimestamp int64 `json:"lastBlockTimestamp"`
}
type NodeTrustData struct {
State int `json:"state"`
Trust int `json:"trust"`
DelegateTo []struct {
A string `json:"a"`
V int64 `json:"v"`
} `json:"delegate_to"`
DelegatedFrom []struct {
A string `json:"a"`
V int64 `json:"v"`
} `json:"delegated_from"`
}
type LastNodeCount struct {
Nodes []struct {
Node string `json:"node"`
IP string `json:"ip"`
Type string `json:"type"`
Count int `json:"count"`
} `json:"nodes"`
Day int `json:"day"`
Lastblockday int `json:"lastBlockDay"`
}
type NodeRaiting struct {
Address string `json:"address"`
Raiting int `json:"raiting"`
Day int `json:"day"`
Lastblockday int `json:"lastBlockDay"`
}
type AddressDelegations struct {
Address string `json:"address"`
States []struct {
To string `json:"to"`
Value int64 `json:"value"`
Tx string `json:"tx"`
} `json:"states"`
}
type ForginSumArgs struct {
BlockIndent int `json:"block_indent"`
}
type ForgingSum struct {
Blocknumber int `json:"blockNumber"`
Sums []struct {
Type int `json:"type"`
Value int64 `json:"value"`
} `json:"sums"`
}
type CommonBalance struct {
Balance int64 `json:"balance"`
}
type TotalSupply struct {
CirculatingSupply string `json:"circulating_supply"` //Number of coins in circulation
CirculatingSupplyCmc string `json:"circulating_supply_cmc"` //Number of coins in circulation (by CoinMarketCap)
TotalSupply string `json:"total_supply"` //Number of all coins emitted
TotalSupplyDecimals string `json:"total_supply_decimals"` //Number of all coins emitted in micro units
MaxSupply string `json:"max_supply"` //Maximum possible number of coins
Decimals int `json:"decimals"` //Number of decimal places
Name string `json:"name"` //Name of the currency
}
type Status struct {
ID int `json:"id"`
Result string `json:"result"`
Version string `json:"version"`
GitHash string `json:"git_hash"`
}