good morning!!!!

Skip to content
Snippets Groups Projects
Commit 158efbaa authored by Jeffrey Wilcke's avatar Jeffrey Wilcke
Browse files

Merge pull request #984 from tgerring/issue924

Omit replies for RPC notification requests
parents 3ac34ee3 44a7f997
No related branches found
No related tags found
No related merge requests found
......@@ -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
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment