diff options
author | obscuren <geffobscura@gmail.com> | 2015-05-16 06:27:13 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-05-16 06:27:13 +0800 |
commit | 1564f1a020b9edc78bc672f8f2df64b3d0dc55c3 (patch) | |
tree | d898e2b20a6c2e0b5613ae7f669499c5db23b719 /rpc | |
parent | 8e24378cc1acb074b56de75bf0baf6feb7927677 (diff) | |
parent | 7ea76fcf993f3fecb55233bdcc2409618d9080b9 (diff) | |
download | go-tangerine-1564f1a020b9edc78bc672f8f2df64b3d0dc55c3.tar go-tangerine-1564f1a020b9edc78bc672f8f2df64b3d0dc55c3.tar.gz go-tangerine-1564f1a020b9edc78bc672f8f2df64b3d0dc55c3.tar.bz2 go-tangerine-1564f1a020b9edc78bc672f8f2df64b3d0dc55c3.tar.lz go-tangerine-1564f1a020b9edc78bc672f8f2df64b3d0dc55c3.tar.xz go-tangerine-1564f1a020b9edc78bc672f8f2df64b3d0dc55c3.tar.zst go-tangerine-1564f1a020b9edc78bc672f8f2df64b3d0dc55c3.zip |
Merge branch 'release/0.9.21'v0.9.21
Diffstat (limited to 'rpc')
-rw-r--r-- | rpc/api.go | 1 | ||||
-rw-r--r-- | rpc/http.go | 24 |
2 files changed, 22 insertions, 3 deletions
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 } |