diff options
-rw-r--r-- | cmd/geth/js_test.go | 2 | ||||
-rw-r--r-- | rpc/api.go | 1 | ||||
-rw-r--r-- | rpc/http.go | 24 | ||||
-rw-r--r-- | xeth/xeth.go | 6 |
4 files changed, 28 insertions, 5 deletions
diff --git a/cmd/geth/js_test.go b/cmd/geth/js_test.go index c2a0e2fe2..e02e8f704 100644 --- a/cmd/geth/js_test.go +++ b/cmd/geth/js_test.go @@ -68,7 +68,7 @@ func testJEthRE(t *testing.T) (string, *testjethre, *eth.Ethereum) { // set up mock genesis with balance on the testAddress core.GenesisData = []byte(testGenesis) - ks := crypto.NewKeyStorePassphrase(filepath.Join(tmp, "keystore")) + ks := crypto.NewKeyStorePlain(filepath.Join(tmp, "keystore")) am := accounts.NewManager(ks) ethereum, err := eth.New(ð.Config{ DataDir: tmp, diff --git a/rpc/api.go b/rpc/api.go index 066c81222..b59253ef7 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -349,6 +349,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err if err != nil { return err } + contract.Code = newHexData(contract.Code).String() *reply = contract case "eth_newFilter": diff --git a/rpc/http.go b/rpc/http.go index c5bb10c80..9b3fa5142 100644 --- a/rpc/http.go +++ b/rpc/http.go @@ -87,7 +87,9 @@ func JSONRPC(pipe *xeth.XEth) http.Handler { var reqSingle RpcRequest if err := json.Unmarshal(body, &reqSingle); err == nil { response := RpcResponse(api, &reqSingle) - send(w, &response) + if reqSingle.Id != nil { + send(w, &response) + } return } @@ -96,11 +98,27 @@ func JSONRPC(pipe *xeth.XEth) http.Handler { if err := json.Unmarshal(body, &reqBatch); err == nil { // Build response batch resBatch := make([]*interface{}, len(reqBatch)) + resCount := 0 + for i, request := range reqBatch { response := RpcResponse(api, &request) - resBatch[i] = response + // this leaves nil entries in the response batch for later removal + if request.Id != nil { + resBatch[i] = response + resCount = resCount + 1 + } } - send(w, resBatch) + + // make response omitting nil entries + respBatchComp := make([]*interface{}, resCount) + for _, v := range resBatch { + if v != nil { + respBatchComp[len(respBatchComp)-resCount] = v + resCount = resCount - 1 + } + } + + send(w, respBatchComp) return } diff --git a/xeth/xeth.go b/xeth/xeth.go index 0fe68d175..0d16393c2 100644 --- a/xeth/xeth.go +++ b/xeth/xeth.go @@ -318,7 +318,11 @@ func (self *XEth) EthTransactionByHash(hash string) (tx *types.Transaction, blha Index uint64 } - v, _ := self.backend.ExtraDb().Get(append(common.FromHex(hash), 0x0001)) + v, dberr := self.backend.ExtraDb().Get(append(common.FromHex(hash), 0x0001)) + // TODO check specifically for ErrNotFound + if dberr != nil { + return + } r := bytes.NewReader(v) err := rlp.Decode(r, &txExtra) if err == nil { |