-
Notifications
You must be signed in to change notification settings - Fork 0
/
mining.go
48 lines (36 loc) · 1.52 KB
/
mining.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
package rpcclient
import (
"github.com/omarhachach/rpcclient-core/types"
)
// GetBlockTemplate returns data needed to construct a block to work on.
// If template is nil, will use default.
func (c *Client) GetBlockTemplate(template *types.BlockTemplateRequest) (*types.BlockTemplate, error) {
var tmplt *types.BlockTemplate
if template != nil {
return tmplt, c.SendReq("getblocktemplate", &tmplt, template)
}
return tmplt, c.SendReq("getblocktemplate", &tmplt)
}
// GetMiningInfo returns mining-related information.
func (c *Client) GetMiningInfo() (*types.MiningInfo, error) {
var info *types.MiningInfo
return info, c.SendReq("getmininginfo", &info)
}
// GetNetworkHashPS returns the estimated network hashes per second based on the last nblocks.
func (c *Client) GetNetworkHashPS(nblocks, height int) (int, error) {
var hsps int
return hsps, c.SendReq("getnetworkhashps", nblocks, height)
}
// PrioritiseTransaction accepts the transaction into mined blocks at a higher (or lower) priority.
func (c *Client) PrioritiseTransaction(txid string, feeDelta int) (bool, error) {
var res bool
return res, c.SendReq("prioritisetransaction", &res, txid, feeDelta)
}
// SubmitBlock submits a new block to the network.
func (c *Client) SubmitBlock(hexdata string) error {
return c.SendReq("submitblock", new(string), hexdata)
}
// SubmitHeader decodes the hexdata as a header and submits it as a candidate chain tip if valid.
func (c *Client) SubmitHeader(hexdata string) error {
return c.SendReq("submitblock", new(string), hexdata)
}