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