aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/jeth.go
diff options
context:
space:
mode:
authorzsfelfoldi <zsfelfoldi@gmail.com>2015-03-20 20:22:01 +0800
committerzsfelfoldi <zsfelfoldi@gmail.com>2015-03-20 20:22:01 +0800
commit8324b683b4e557e6c5c9d572d01f933b3e074185 (patch)
tree8c6a8c34d87f808c3979875642d4ca38844ad22d /rpc/jeth.go
parent91f9f355b2e334214e38e1827c624cdcc23c5130 (diff)
downloadgo-tangerine-8324b683b4e557e6c5c9d572d01f933b3e074185.tar
go-tangerine-8324b683b4e557e6c5c9d572d01f933b3e074185.tar.gz
go-tangerine-8324b683b4e557e6c5c9d572d01f933b3e074185.tar.bz2
go-tangerine-8324b683b4e557e6c5c9d572d01f933b3e074185.tar.lz
go-tangerine-8324b683b4e557e6c5c9d572d01f933b3e074185.tar.xz
go-tangerine-8324b683b4e557e6c5c9d572d01f933b3e074185.tar.zst
go-tangerine-8324b683b4e557e6c5c9d572d01f933b3e074185.zip
using robertkrimen/otto, godeps updated
Diffstat (limited to 'rpc/jeth.go')
-rw-r--r--rpc/jeth.go27
1 files changed, 19 insertions, 8 deletions
diff --git a/rpc/jeth.go b/rpc/jeth.go
index 11d4599c9..4e83be8a6 100644
--- a/rpc/jeth.go
+++ b/rpc/jeth.go
@@ -3,22 +3,29 @@ package rpc
import (
"encoding/json"
// "fmt"
- "github.com/obscuren/otto"
+ "github.com/ethereum/go-ethereum/jsre"
+ "github.com/robertkrimen/otto"
)
type Jeth struct {
ethApi *EthereumApi
toVal func(interface{}) otto.Value
+ re *jsre.JSRE
}
-func NewJeth(ethApi *EthereumApi, toVal func(interface{}) otto.Value) *Jeth {
- return &Jeth{ethApi, toVal}
+func NewJeth(ethApi *EthereumApi, toVal func(interface{}) otto.Value, re *jsre.JSRE) *Jeth {
+ return &Jeth{ethApi, toVal, re}
}
-func (self *Jeth) err(code int, msg string, id interface{}) otto.Value {
+func (self *Jeth) err(code int, msg string, id interface{}) (response otto.Value) {
rpcerr := &RpcErrorObject{code, msg}
- rpcresponse := &RpcErrorResponse{Jsonrpc: jsonrpcver, Id: id, Error: rpcerr}
- return self.toVal(rpcresponse)
+ self.re.Set("ret_jsonrpc", jsonrpcver)
+ self.re.Set("ret_id", id)
+ self.re.Set("ret_error", rpcerr)
+ response, _ = self.re.Run(`
+ ret_response = { jsonrpc: ret_jsonrpc, id: ret_id, error: ret_error };
+ `)
+ return
}
func (self *Jeth) Send(call otto.FunctionCall) (response otto.Value) {
@@ -37,7 +44,11 @@ func (self *Jeth) Send(call otto.FunctionCall) (response otto.Value) {
if err != nil {
return self.err(-32603, err.Error(), req.Id)
}
- rpcresponse := &RpcSuccessResponse{Jsonrpc: jsonrpcver, Id: req.Id, Result: respif}
- response = self.toVal(rpcresponse)
+ self.re.Set("ret_jsonrpc", jsonrpcver)
+ self.re.Set("ret_id", req.Id)
+ self.re.Set("ret_result", respif)
+ response, err = self.re.Run(`
+ ret_response = { jsonrpc: ret_jsonrpc, id: ret_id, result: ret_result };
+ `)
return
}