aboutsummaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-02-26 18:14:33 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-02-26 18:14:33 +0800
commit9884eed0cf7c95074fd5b3d5f0f592a423810a8a (patch)
treef9bc30f7dc317e7c58816a9ec8b5459d2f7a619a /rpc
parent5b202a158adedfea4d0be734e473bccdf103d987 (diff)
parent9e0ab22dd01d677a853f1af2c865f8654081ca26 (diff)
downloaddexon-9884eed0cf7c95074fd5b3d5f0f592a423810a8a.tar
dexon-9884eed0cf7c95074fd5b3d5f0f592a423810a8a.tar.gz
dexon-9884eed0cf7c95074fd5b3d5f0f592a423810a8a.tar.bz2
dexon-9884eed0cf7c95074fd5b3d5f0f592a423810a8a.tar.lz
dexon-9884eed0cf7c95074fd5b3d5f0f592a423810a8a.tar.xz
dexon-9884eed0cf7c95074fd5b3d5f0f592a423810a8a.tar.zst
dexon-9884eed0cf7c95074fd5b3d5f0f592a423810a8a.zip
Merge pull request #392 from tgerring/rpcdefaultblock
Stub defaultBlock RPC methods
Diffstat (limited to 'rpc')
-rw-r--r--rpc/api.go21
-rw-r--r--rpc/messages.go13
2 files changed, 34 insertions, 0 deletions
diff --git a/rpc/api.go b/rpc/api.go
index 21c85bbcc..908d37a80 100644
--- a/rpc/api.go
+++ b/rpc/api.go
@@ -45,6 +45,8 @@ type EthereumApi struct {
register map[string][]*NewTxArgs
db ethutil.Database
+
+ defaultBlockAge int
}
func NewEthereumApi(eth *xeth.XEth) *EthereumApi {
@@ -318,6 +320,17 @@ func (p *EthereumApi) SetMining(shouldmine bool, reply *interface{}) error {
return nil
}
+func (p *EthereumApi) GetDefaultBlockAge(reply *interface{}) error {
+ *reply = p.defaultBlockAge
+ return nil
+}
+
+func (p *EthereumApi) SetDefaultBlockAge(defaultBlockAge int, reply *interface{}) error {
+ p.defaultBlockAge = defaultBlockAge
+ *reply = true
+ return nil
+}
+
func (p *EthereumApi) BlockNumber(reply *interface{}) error {
*reply = p.xeth.Backend().ChainManager().CurrentBlock().Number()
return nil
@@ -458,6 +471,14 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return err
}
return p.SetMining(args, reply)
+ case "eth_defaultBlock":
+ return p.GetDefaultBlockAge(reply)
+ case "eth_setDefaultBlock":
+ args, err := req.ToIntArgs()
+ if err != nil {
+ return err
+ }
+ return p.SetDefaultBlockAge(args, reply)
case "eth_peerCount":
return p.GetPeerCount(reply)
case "eth_number":
diff --git a/rpc/messages.go b/rpc/messages.go
index 044f07545..b37d8229d 100644
--- a/rpc/messages.go
+++ b/rpc/messages.go
@@ -210,6 +210,19 @@ func (req *RpcRequest) ToBoolArgs() (bool, error) {
return args, nil
}
+func (req *RpcRequest) ToIntArgs() (int, error) {
+ if len(req.Params) < 1 {
+ return 0, errArguments
+ }
+
+ var args int
+ if err := json.Unmarshal(req.Params[0], &args); err != nil {
+ return 0, errArguments
+ }
+
+ return args, nil
+}
+
func (req *RpcRequest) ToCompileArgs() (string, error) {
if len(req.Params) < 1 {
return "", errArguments