Move remote mining agent to XEth

This commit is contained in:
Taylor Gerring
2015-03-23 09:35:42 +01:00
parent d76e8cb1f1
commit ab6311c1bd
3 changed files with 93 additions and 9 deletions

View File

@ -17,20 +17,15 @@ type EthereumApi struct {
eth *xeth.XEth
xethMu sync.RWMutex
db common.Database
// Miner agent
agent *Agent
}
func NewEthereumApi(xeth *xeth.XEth, dataDir string) *EthereumApi {
// What about when dataDir is empty?
db, _ := ethdb.NewLDBDatabase(path.Join(dataDir, "dapps"))
api := &EthereumApi{
eth: xeth,
db: db,
agent: NewAgent(),
eth: xeth,
db: db,
}
xeth.Backend().Miner().Register(api.agent)
return api
}
@ -349,13 +344,13 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
*reply = NewLogsRes(api.xeth().AllLogs(opts))
case "eth_getWork":
api.xeth().SetMining(true)
*reply = api.agent.GetWork()
*reply = api.xeth().RemoteMining().GetWork()
case "eth_submitWork":
args := new(SubmitWorkArgs)
if err := json.Unmarshal(req.Params, &args); err != nil {
return err
}
*reply = api.agent.SetResult(args.Nonce, args.Digest, args.Header)
*reply = api.xeth().RemoteMining().SubmitWork(args.Nonce, args.Digest, args.Header)
case "db_putString":
args := new(DbArgs)
if err := json.Unmarshal(req.Params, &args); err != nil {