forked from qtumproject/janus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eth_mining.go
37 lines (29 loc) · 894 Bytes
/
eth_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
package transformer
import (
"context"
"github.com/kaonone/eth-rpc-gate/pkg/eth"
"github.com/kaonone/eth-rpc-gate/pkg/kaon"
"github.com/labstack/echo"
)
// ProxyETHGetHashrate implements ETHProxy
type ProxyETHMining struct {
*kaon.Kaon
}
func (p *ProxyETHMining) Method() string {
return "eth_mining"
}
func (p *ProxyETHMining) Request(_ *eth.JSONRPCRequest, c echo.Context) (interface{}, *eth.JSONRPCError) {
return p.request(c.Request().Context())
}
func (p *ProxyETHMining) request(ctx context.Context) (*eth.MiningResponse, *eth.JSONRPCError) {
kaonresp, err := p.Kaon.GetMining(ctx)
if err != nil {
return nil, eth.NewCallbackError(err.Error())
}
// kaon res -> eth res
return p.ToResponse(kaonresp), nil
}
func (p *ProxyETHMining) ToResponse(kaonresp *kaon.GetMiningResponse) *eth.MiningResponse {
ethresp := eth.MiningResponse(kaonresp.Staking)
return ðresp
}