mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 09:53:48 +00:00
update add ethclient.HashRate ethclient.GetWork
This commit is contained in:
parent
a9e4a90d57
commit
d0431270c1
1 changed files with 18 additions and 0 deletions
|
|
@ -476,6 +476,24 @@ func (ec *Client) SendTransaction(ctx context.Context, tx *types.Transaction) er
|
||||||
return ec.c.CallContext(ctx, nil, "eth_sendRawTransaction", common.ToHex(data))
|
return ec.c.CallContext(ctx, nil, "eth_sendRawTransaction", common.ToHex(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ec *Client) HashRate(ctx context.Context) (uint64, error) {
|
||||||
|
var hex hexutil.Uint64
|
||||||
|
err := ec.c.CallContext(ctx, &hex, "eth_hashrate")
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return uint64(hex), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ec *Client) GetWork(ctx context.Context) ([3]string, error) {
|
||||||
|
var result [3]string
|
||||||
|
err := ec.c.CallContext(ctx, &result, "eth_getWork")
|
||||||
|
if err != nil {
|
||||||
|
return [3]string{}, err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
func toCallArg(msg ethereum.CallMsg) interface{} {
|
func toCallArg(msg ethereum.CallMsg) interface{} {
|
||||||
arg := map[string]interface{}{
|
arg := map[string]interface{}{
|
||||||
"from": msg.From,
|
"from": msg.From,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue