aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/api.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-03-22 22:38:01 +0800
committerobscuren <geffobscura@gmail.com>2015-03-22 22:38:01 +0800
commit82956df523fd75d0c3b4a49f571eee60935fc32e (patch)
treed30856ceb5e789e90f9750601a09b595b91bd71e /rpc/api.go
parent9682a3ef3ec72a871708a9bba1133fa59b58ccb5 (diff)
downloaddexon-82956df523fd75d0c3b4a49f571eee60935fc32e.tar.gz
dexon-82956df523fd75d0c3b4a49f571eee60935fc32e.tar.zst
dexon-82956df523fd75d0c3b4a49f571eee60935fc32e.zip
Get work / submit work partially implemented.
* WIP missing arguments for submitting new work * GetWork **done**
Diffstat (limited to 'rpc/api.go')
-rw-r--r--rpc/api.go23
1 files changed, 20 insertions, 3 deletions
diff --git a/rpc/api.go b/rpc/api.go
index 34d4ff0fc..d5e18eec8 100644
--- a/rpc/api.go
+++ b/rpc/api.go
@@ -17,15 +17,20 @@ type EthereumApi struct {
eth *xeth.XEth
xethMu sync.RWMutex
db common.Database
+
+ // Miner agent
+ agent *Agent
}
func NewEthereumApi(eth *xeth.XEth, dataDir string) *EthereumApi {
// What about when dataDir is empty?
db, _ := ethdb.NewLDBDatabase(path.Join(dataDir, "dapps"))
api := &EthereumApi{
- eth: eth,
- db: db,
+ eth: eth,
+ db: db,
+ agent: NewAgent(),
}
+ eth.Backend().Miner().Register(api.agent)
return api
}
@@ -342,7 +347,13 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
}
opts := toFilterOptions(args)
*reply = NewLogsRes(p.xeth().AllLogs(opts))
- case "eth_getWork", "eth_submitWork":
+ case "eth_getWork":
+ *reply = p.getWork()
+ case "eth_submitWork":
+ // TODO what is the reply here?
+ // TODO what are the arguments?
+ p.agent.SetResult(0, common.Hash{}, common.Hash{})
+
return NewNotImplementedError(req.Method)
case "db_putString":
args := new(DbArgs)
@@ -427,6 +438,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return err
}
*reply = p.xeth().Whisper().Messages(args.Id)
+
// case "eth_register":
// // Placeholder for actual type
// args := new(HashIndexArgs)
@@ -454,6 +466,11 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return nil
}
+func (p *EthereumApi) getWork() string {
+ p.xeth().SetMining(true)
+ return p.agent.GetWork().Hex()
+}
+
func toFilterOptions(options *BlockFilterArgs) *core.FilterOptions {
var opts core.FilterOptions