This repository has been archived by the owner on Feb 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
models.go
366 lines (288 loc) · 10.3 KB
/
models.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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
package pooldb
import (
"time"
"github.com/magicpool-co/pool/pkg/dbcl"
)
type Chain struct {
ID string `json:"id"`
Mineable bool `json:"mineable"`
Switchable bool `json:"switchable"`
Payable bool `json:"payable"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
type Node struct {
URL string `db:"url"`
ChainID string `db:"chain_id"`
Region string `db:"region"`
Version *string `db:"version"`
Mainnet bool `db:"mainnet"`
Enabled bool `db:"enabled"`
Backup bool `db:"backup"`
Active bool `db:"active"`
Synced bool `db:"synced"`
Height *uint64 `db:"height"`
NeedsBackup bool `db:"needs_backup"`
PendingBackup bool `db:"pending_backup"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
DownAt *time.Time `db:"down_at"`
BackupAt *time.Time `db:"backup_at"`
}
/* pool */
type Miner struct {
ID uint64 `db:"id"`
ChainID string `db:"chain_id"`
Address string `db:"address"`
Email *string `db:"email"`
Threshold dbcl.NullBigInt `db:"threshold"`
Active bool `db:"active"`
EnabledWorkerNotifications bool `db:"enabled_worker_notifications"`
EnabledPayoutNotifications bool `db:"enabled_payout_notifications"`
RecipientFeePercent *uint64 `db:"recipient_fee_percent"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
// column not present in the table, only
// helpful for a specific join query (GetActiveWorkers)
LastShare time.Time `db:"last_share"`
}
type Worker struct {
ID uint64 `db:"id"`
MinerID uint64 `db:"miner_id"`
Name string `db:"name"`
Active bool `db:"active"`
Notified bool `db:"notified"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
// column not present in the table, only
// helpful for a specific join query (GetWorkersByMinerID)
LastDifficulty *float64 `db:"last_difficulty"`
LastShare time.Time `db:"last_share"`
}
type IPAddress struct {
ChainID string `db:"chain_id"`
MinerID uint64 `db:"miner_id"`
WorkerID uint64 `db:"worker_id"`
IPAddress string `db:"ip_address"`
Active bool `db:"active"`
Expired bool `db:"expired"`
LastShare time.Time `db:"last_share"`
LastDifficulty *float64 `db:"last_difficulty"`
RoundTripTime *float64 `db:"rtt"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
type Round struct {
ID uint64 `db:"id"`
ChainID string `db:"chain_id"`
MinerID uint64 `db:"miner_id"`
// column not present in the table, only
// helpful for a specific join query (GetRounds)
Miner *string `db:"miner"`
Solo bool `db:"solo"`
Height uint64 `db:"height"`
UncleHeight *uint64 `db:"uncle_height"`
EpochHeight *uint64 `db:"epoch_height"`
Hash string `db:"hash"`
Nonce *uint64 `db:"nonce"`
MixDigest *string `db:"mix_digest"`
Solution *string `db:"solution"`
CoinbaseTxID *string `db:"coinbase_txid"`
Value dbcl.NullBigInt `db:"value"`
AcceptedShares uint64 `db:"accepted_shares"`
RejectedShares uint64 `db:"rejected_shares"`
InvalidShares uint64 `db:"invalid_shares"`
Difficulty uint64 `db:"difficulty"`
Luck float64 `db:"luck"`
// column not present in the table, only helpful for
// a specific join query (GetRoundsByMiner)
MinerValue dbcl.NullBigInt `db:"miner_value"`
Pending bool `db:"pending"`
Uncle bool `db:"uncle"`
Orphan bool `db:"orphan"`
Mature bool `db:"mature"`
Spent bool `db:"spent"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
type Share struct {
ID uint64 `db:"id"`
RoundID uint64 `db:"round_id"`
MinerID uint64 `db:"miner_id"`
Count uint64 `db:"count"`
CreatedAt time.Time `db:"created_at"`
}
/* transaction */
type Transaction struct {
ID uint64 `db:"id"`
ChainID string `db:"chain_id"`
Type int `db:"type"`
TxID string `db:"txid"`
TxHex string `db:"tx_hex"`
Height *uint64 `db:"height"`
Value dbcl.NullBigInt `db:"value"`
Fee dbcl.NullBigInt `db:"fee"`
FeeBalance dbcl.NullBigInt `db:"fee_balance"`
Remainder dbcl.NullBigInt `db:"remainder"`
RemainderIdx uint32 `db:"remainder_idx"`
Spent bool `db:"spent"`
Confirmed bool `db:"confirmed"`
Failed bool `db:"failed"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
type UTXO struct {
ID uint64 `db:"id"`
ChainID string `db:"chain_id"`
TransactionID *uint64 `db:"transaction_id"`
Value dbcl.NullBigInt `db:"value"`
TxID string `db:"txid"`
Index uint32 `db:"idx"`
Active bool `db:"active"`
Spent bool `db:"spent"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
/* exchange */
type ExchangeBatch struct {
ID uint64 `db:"id"`
ExchangeID int `db:"exchange_id"`
Status int `db:"status"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
CompletedAt *time.Time `db:"completed_at"`
}
type ExchangeInput struct {
ID uint64 `db:"id"`
BatchID uint64 `db:"batch_id"`
InChainID string `db:"in_chain_id"`
OutChainID string `db:"out_chain_id"`
Value dbcl.NullBigInt `db:"value"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
type ExchangeDeposit struct {
ID uint64 `db:"id"`
BatchID uint64 `db:"batch_id"`
ChainID string `db:"chain_id"`
NetworkID string `db:"network_id"`
TransactionID *uint64 `db:"transaction_id"`
DepositTxID string `db:"deposit_txid"`
ExchangeTxID *string `db:"exchange_txid"`
ExchangeDepositID *string `db:"exchange_deposit_id"`
Value dbcl.NullBigInt `db:"value"`
Fees dbcl.NullBigInt `db:"fees"`
Registered bool `db:"registered"`
Confirmed bool `db:"confirmed"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
type ExchangeTrade struct {
ID uint64 `db:"id"`
BatchID uint64 `db:"batch_id"`
PathID int `db:"path_id"`
StageID int `db:"stage_id"`
StepID int `db:"step_id"`
IsMarketOrder bool `db:"is_market_order"`
TradeStrategy int `db:"trade_strategy"`
ExchangeTradeID *string `db:"exchange_trade_id"`
InitialChainID string `db:"initial_chain_id"`
FromChainID string `db:"from_chain_id"`
ToChainID string `db:"to_chain_id"`
Market string `db:"market"`
Direction int `db:"direction"`
Value dbcl.NullBigInt `db:"value"`
Proceeds dbcl.NullBigInt `db:"proceeds"`
TradeFees dbcl.NullBigInt `db:"trade_fees"`
CumulativeDepositFees dbcl.NullBigInt `db:"cumulative_deposit_fees"`
CumulativeTradeFees dbcl.NullBigInt `db:"cumulative_trade_fees"`
OrderPrice *float64 `db:"order_price"`
FillPrice *float64 `db:"fill_price"`
CumulativeFillPrice *float64 `db:"cumulative_fill_price"`
Slippage *float64 `db:"slippage"`
Initiated bool `db:"initiated"`
Confirmed bool `db:"confirmed"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
type ExchangeWithdrawal struct {
ID uint64 `db:"id"`
BatchID uint64 `db:"batch_id"`
ChainID string `db:"chain_id"`
NetworkID string `db:"network_id"`
ExchangeTxID *string `db:"exchange_txid"`
ExchangeWithdrawalID string `db:"exchange_withdrawal_id"`
Value dbcl.NullBigInt `db:"value"`
DepositFees dbcl.NullBigInt `db:"deposit_fees"`
TradeFees dbcl.NullBigInt `db:"trade_fees"`
WithdrawalFees dbcl.NullBigInt `db:"withdrawal_fees"`
CumulativeFees dbcl.NullBigInt `db:"cumulative_fees"`
Confirmed bool `db:"confirmed"`
Spent bool `db:"spent"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
/* balance */
type Payout struct {
ID uint64 `db:"id"`
ChainID string `db:"chain_id"`
MinerID uint64 `db:"miner_id"`
Address string `db:"address"`
TransactionID *uint64 `db:"transaction_id"`
TxID string `db:"txid"`
Height *uint64 `db:"height"`
Value dbcl.NullBigInt `db:"value"`
FeeBalance dbcl.NullBigInt `db:"fee_balance"`
PoolFees dbcl.NullBigInt `db:"pool_fees"`
ExchangeFees dbcl.NullBigInt `db:"exchange_fees"`
TxFees dbcl.NullBigInt `db:"tx_fees"`
Pending bool `db:"pending"`
Confirmed bool `db:"confirmed"`
Failed bool `db:"failed"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
type BalanceInput struct {
ID uint64 `db:"id"`
RoundID uint64 `db:"round_id"`
ChainID string `db:"chain_id"`
MinerID uint64 `db:"miner_id"`
OutChainID string `db:"out_chain_id"`
BalanceOutputID *uint64 `db:"balance_output_id"`
BatchID *uint64 `db:"batch_id"`
// column not present in table, helpful for balance input
// sum query for each payout
PayoutID uint64 `db:"payout_id"`
Value dbcl.NullBigInt `db:"value"`
PoolFees dbcl.NullBigInt `db:"pool_fees"`
Mature bool `db:"mature"`
Pending bool `db:"pending"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
type BalanceOutput struct {
ID uint64 `db:"id"`
ChainID string `db:"chain_id"`
MinerID uint64 `db:"miner_id"`
InBatchID *uint64 `db:"in_batch_id"`
InDepositID *uint64 `db:"in_deposit_id"`
InPayoutID *uint64 `db:"in_payout_id"`
OutPayoutID *uint64 `db:"out_payout_id"`
OutMergeTransactionID *uint64 `db:"out_merge_transaction_id"`
Value dbcl.NullBigInt `db:"value"`
PoolFees dbcl.NullBigInt `db:"pool_fees"`
ExchangeFees dbcl.NullBigInt `db:"exchange_fees"`
TxFees dbcl.NullBigInt `db:"tx_fees"`
Mature bool `db:"mature"`
Spent bool `db:"spent"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
type BalanceSum struct {
ChainID string `db:"chain_id"`
MinerID uint64 `db:"miner_id"`
ImmatureValue dbcl.NullBigInt `db:"immature_value"`
MatureValue dbcl.NullBigInt `db:"mature_value"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}