forked from qtumproject/janus
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patheth_mining.go
37 lines (29 loc) · 919 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/labstack/echo"
"github.com/denuoweb/janus/pkg/eth"
"github.com/denuoweb/janus/pkg/htmlcoin"
)
//ProxyETHGetHashrate implements ETHProxy
type ProxyETHMining struct {
*htmlcoin.Htmlcoin
}
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) {
htmlcoinresp, err := p.Htmlcoin.GetMining(ctx)
if err != nil {
return nil, eth.NewCallbackError(err.Error())
}
// htmlcoin res -> eth res
return p.ToResponse(htmlcoinresp), nil
}
func (p *ProxyETHMining) ToResponse(htmlcoinresp *htmlcoin.GetMiningResponse) *eth.MiningResponse {
ethresp := eth.MiningResponse(htmlcoinresp.Staking)
return ðresp
}