aboutsummaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-02-20 22:18:32 +0800
committerobscuren <geffobscura@gmail.com>2015-02-20 22:18:32 +0800
commit82cae277372095eb221bc14b2111e46c468925fd (patch)
treef45334ddc09a191c8dfe4e75f98f736bf67979f6 /rpc
parentea9a549bbdc8377bca73f1417f2dc4a18396a382 (diff)
parent75625801f597061076d1e5863f97c9ea12aa10e4 (diff)
downloaddexon-82cae277372095eb221bc14b2111e46c468925fd.tar.gz
dexon-82cae277372095eb221bc14b2111e46c468925fd.tar.zst
dexon-82cae277372095eb221bc14b2111e46c468925fd.zip
Merge branch 'tgerring-rpcupdates' into develop
Diffstat (limited to 'rpc')
-rw-r--r--rpc/message.go60
-rw-r--r--rpc/packages.go47
2 files changed, 107 insertions, 0 deletions
diff --git a/rpc/message.go b/rpc/message.go
index d96c35d7e..825ede05b 100644
--- a/rpc/message.go
+++ b/rpc/message.go
@@ -201,6 +201,36 @@ func (req *RpcRequest) ToGetCodeAtArgs() (*GetCodeAtArgs, error) {
return args, nil
}
+func (req *RpcRequest) ToBoolArgs() (bool, error) {
+ if len(req.Params) < 1 {
+ return false, NewErrorResponse(ErrorArguments)
+ }
+
+ var args bool
+ err := json.Unmarshal(req.Params[0], &args)
+ if err != nil {
+ return false, NewErrorResponse(ErrorDecodeArgs)
+ }
+
+ rpclogger.DebugDetailf("%T %v", args, args)
+ return args, nil
+}
+
+func (req *RpcRequest) ToCompileArgs() (string, error) {
+ if len(req.Params) < 1 {
+ return "", NewErrorResponse(ErrorArguments)
+ }
+
+ var args string
+ err := json.Unmarshal(req.Params[0], &args)
+ if err != nil {
+ return "", NewErrorResponse(ErrorDecodeArgs)
+ }
+
+ rpclogger.DebugDetailf("%T %v", args, args)
+ return args, nil
+}
+
func (req *RpcRequest) ToFilterArgs() (*FilterOptions, error) {
if len(req.Params) < 1 {
return nil, NewErrorResponse(ErrorArguments)
@@ -231,6 +261,36 @@ func (req *RpcRequest) ToFilterStringArgs() (string, error) {
return args, nil
}
+func (req *RpcRequest) ToUninstallFilterArgs() (int, error) {
+ if len(req.Params) < 1 {
+ return 0, NewErrorResponse(ErrorArguments)
+ }
+
+ var args int
+ err := json.Unmarshal(req.Params[0], &args)
+ if err != nil {
+ return 0, NewErrorResponse(ErrorDecodeArgs)
+ }
+
+ rpclogger.DebugDetailf("%T %v", args, args)
+ return args, nil
+}
+
+func (req *RpcRequest) ToFilterChangedArgs() (int, error) {
+ if len(req.Params) < 1 {
+ return 0, NewErrorResponse(ErrorArguments)
+ }
+
+ var id int
+ r := bytes.NewReader(req.Params[0])
+ err := json.NewDecoder(r).Decode(&id)
+ if err != nil {
+ return 0, NewErrorResponse(ErrorDecodeArgs)
+ }
+ rpclogger.DebugDetailf("%T %v", id, id)
+ return id, nil
+}
+
func (req *RpcRequest) ToDbPutArgs() (*DbArgs, error) {
if len(req.Params) < 3 {
return nil, NewErrorResponse(ErrorArguments)
diff --git a/rpc/packages.go b/rpc/packages.go
index 7411392c2..56c1751d7 100644
--- a/rpc/packages.go
+++ b/rpc/packages.go
@@ -113,6 +113,13 @@ func (self *EthereumApi) NewFilter(args *FilterOptions, reply *interface{}) erro
return nil
}
+func (self *EthereumApi) UninstallFilter(id int, reply *interface{}) error {
+ delete(self.logs, id)
+ self.filterManager.UninstallFilter(id)
+ *reply = true
+ return nil
+}
+
func (self *EthereumApi) NewFilterString(args string, reply *interface{}) error {
var id int
filter := core.NewFilter(self.xeth.Backend())
@@ -273,6 +280,11 @@ func (p *EthereumApi) GetIsMining(reply *interface{}) error {
return nil
}
+func (p *EthereumApi) SetMining(shouldmine bool, reply *interface{}) error {
+ *reply = p.xeth.SetMining(shouldmine)
+ return nil
+}
+
func (p *EthereumApi) BlockNumber(reply *interface{}) error {
*reply = p.xeth.Backend().ChainManager().CurrentBlock().Number()
return nil
@@ -306,6 +318,21 @@ func (p *EthereumApi) GetCodeAt(args *GetCodeAtArgs, reply *interface{}) error {
return nil
}
+func (p *EthereumApi) GetCompilers(reply *interface{}) error {
+ c := []string{"serpent"}
+ *reply = c
+ return nil
+}
+
+func (p *EthereumApi) CompileSerpent(script string, reply *interface{}) error {
+ res, err := ethutil.Compile(script, false)
+ if err != nil {
+ return err
+ }
+ *reply = res
+ return nil
+}
+
func (p *EthereumApi) Sha3(args *Sha3Args, reply *interface{}) error {
*reply = toHex(crypto.Sha3(fromHex(args.Data)))
return nil
@@ -394,6 +421,12 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return p.GetIsListening(reply)
case "eth_mining":
return p.GetIsMining(reply)
+ case "eth_setMining":
+ args, err := req.ToBoolArgs()
+ if err != nil {
+ return err
+ }
+ return p.SetMining(args, reply)
case "eth_peerCount":
return p.GetPeerCount(reply)
case "eth_number":
@@ -460,6 +493,12 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return err
}
return p.NewFilterString(args, reply)
+ case "eth_uninstallFilter":
+ args, err := req.ToUninstallFilterArgs()
+ if err != nil {
+ return err
+ }
+ return p.UninstallFilter(args, reply)
case "eth_changed":
args, err := req.ToIdArgs()
if err != nil {
@@ -493,6 +532,14 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return err
}
return p.WatchTx(args, reply)
+ case "eth_compilers":
+ return p.GetCompilers(reply)
+ case "eth_serpent":
+ args, err := req.ToCompileArgs()
+ if err != nil {
+ return err
+ }
+ return p.CompileSerpent(args, reply)
case "web3_sha3":
args, err := req.ToSha3Args()
if err != nil {