-
Notifications
You must be signed in to change notification settings - Fork 0
/
miningpool.go
102 lines (84 loc) · 3.43 KB
/
miningpool.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
package modules
import (
"time"
"SiaPrime/types"
)
const (
// PoolDir names the directory that contains the pool persistence.
PoolDir = "miningpool"
)
var (
// Whatever variables we need as we go
)
type (
// PoolInternalSettings contains a list of settings that can be changed.
PoolInternalSettings struct {
PoolNetworkPort int `json:"networkport"`
PoolName string `json:"name"`
PoolID uint64 `json:"poolid"`
PoolDBConnection string `json:"dbconnection"`
PoolRedisConnection *map[string]interface{} `json:"redisconnection"`
PoolWallet types.UnlockHash `json:"poolwallet"`
}
// PoolClient contains summary info for a mining client
PoolClient struct {
ClientName string `json:"clientname"`
Balance string `json:"balance"`
BlocksMined uint64 `json:"blocksminer"`
Workers []PoolWorker `json:"workers"`
}
// PoolClientTransaction represents a mining client transaction
PoolClientTransaction struct {
BalanceChange string `json:"balancechange"`
TxTime time.Time `json:"txtime"`
Memo string `json:"memo"`
}
// PoolWorker represents a mining client worker
PoolWorker struct {
WorkerName string `json:"workername"`
LastShareTime time.Time `json:"lastsharetime"`
CurrentDifficulty float64 `json:"currentdifficulty"`
CumulativeDifficulty float64 `json:"cumulativedifficulty"`
SharesThisBlock uint64 `json:"sharesthisblock"`
InvalidSharesThisBlock uint64 `json:"invalidsharesthisblock"`
StaleSharesThisBlock uint64 `json:"stalesharesthisblock"`
BlocksFound uint64 `json:"blocksfound"`
}
// PoolBlock represents a block mined by the pool
PoolBlock struct {
BlockNumber uint64 `json:"blocknumber"`
BlockHeight uint64 `json:"blockheight"`
BlockReward string `json:"blockreward"`
BlockTime time.Time `json:"blocktime"`
BlockStatus string `json:"blockstatus"`
}
// PoolBlockClient represents a block mined by the pool
PoolBlockClient struct {
ClientName string `json:"clientname"`
ClientPercentage float64 `json:"clientpercentage"`
ClientReward string `json:"clientreward"`
}
// PoolWorkingStatus reports the working state of a pool. Can be one of
// "starting", "accepting", or "not accepting".
PoolWorkingStatus string
// PoolConnectabilityStatus reports the connectability state of a pool. Can be
// one of "checking", "connectable", or "not connectable"
PoolConnectabilityStatus string
// A Pool accepts incoming target solutions, tracks the share (an attempted solution),
// checks to see if we have a new block, and if so, pays all the share submitters,
// proportionally based on their share of the solution (minus a percentage to the
// pool operator )
Pool interface {
// InternalSettings returns the pool's internal settings, including
// potentially private or sensitive information.
InternalSettings() PoolInternalSettings
// SetInternalSettings sets the parameters of the pool.
SetInternalSettings(PoolInternalSettings) error
// Close closes the Pool.
Close() error
// Returns the number of open tcp connections the pool currently is servicing
NumConnections() int
// Returns the number of open tcp connections the pool has opened since startup
NumConnectionsOpened() uint64
}
)