Add JSON RPC batch support

http://www.jsonrpc.org/specification#batch
This commit is contained in:
Taylor Gerring
2015-03-17 17:38:05 -04:00
parent fe819f3b9f
commit 8fd243ee23
2 changed files with 53 additions and 52 deletions

View File

@ -21,7 +21,7 @@ import (
"fmt"
"io"
"math/big"
"net/http"
// "net/http"
"reflect"
"time"
@ -106,24 +106,6 @@ func (self JsonWrapper) Send(writer io.Writer, v interface{}) (n int, err error)
return writer.Write(payload)
}
func (self JsonWrapper) ParseRequestBody(req *http.Request) (RpcRequest, error) {
var reqParsed RpcRequest
// Convert JSON to native types
d := json.NewDecoder(req.Body)
defer req.Body.Close()
err := d.Decode(&reqParsed)
if err != nil {
rpclogger.Errorln("Error decoding JSON: ", err)
return reqParsed, err
}
rpclogger.DebugDetailf("Parsed request: %s", reqParsed)
return reqParsed, nil
}
func toHex(b []byte) string {
hex := common.Bytes2Hex(b)
// Prefer output of "0x0" instead of "0x"