aboutsummaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2018-06-11 18:15:59 +0800
committerPéter Szilágyi <peterke@gmail.com>2018-06-11 18:56:22 +0800
commit99483e85b92e07078291442bf1cd4c0db22a262d (patch)
tree4447ef6273f11e11653beb316b8904c5d9ef0851 /rpc
parent1d666cf27ec366a967d9afa0e8a370cb4cf33481 (diff)
downloadgo-tangerine-99483e85b92e07078291442bf1cd4c0db22a262d.tar
go-tangerine-99483e85b92e07078291442bf1cd4c0db22a262d.tar.gz
go-tangerine-99483e85b92e07078291442bf1cd4c0db22a262d.tar.bz2
go-tangerine-99483e85b92e07078291442bf1cd4c0db22a262d.tar.lz
go-tangerine-99483e85b92e07078291442bf1cd4c0db22a262d.tar.xz
go-tangerine-99483e85b92e07078291442bf1cd4c0db22a262d.tar.zst
go-tangerine-99483e85b92e07078291442bf1cd4c0db22a262d.zip
rpc: support returning nil pointer big.Ints (null)
Diffstat (limited to 'rpc')
-rw-r--r--rpc/json.go8
-rw-r--r--rpc/server.go1
-rw-r--r--rpc/utils.go15
3 files changed, 0 insertions, 24 deletions
diff --git a/rpc/json.go b/rpc/json.go
index 837011f51..a523eeb8e 100644
--- a/rpc/json.go
+++ b/rpc/json.go
@@ -320,9 +320,6 @@ func parsePositionalArguments(rawArgs json.RawMessage, types []reflect.Type) ([]
// CreateResponse will create a JSON-RPC success response with the given id and reply as result.
func (c *jsonCodec) CreateResponse(id interface{}, reply interface{}) interface{} {
- if isHexNum(reflect.TypeOf(reply)) {
- return &jsonSuccessResponse{Version: jsonrpcVersion, Id: id, Result: fmt.Sprintf(`%#x`, reply)}
- }
return &jsonSuccessResponse{Version: jsonrpcVersion, Id: id, Result: reply}
}
@@ -340,11 +337,6 @@ func (c *jsonCodec) CreateErrorResponseWithInfo(id interface{}, err Error, info
// CreateNotification will create a JSON-RPC notification with the given subscription id and event as params.
func (c *jsonCodec) CreateNotification(subid, namespace string, event interface{}) interface{} {
- if isHexNum(reflect.TypeOf(event)) {
- return &jsonNotification{Version: jsonrpcVersion, Method: namespace + notificationMethodSuffix,
- Params: jsonSubscription{Subscription: subid, Result: fmt.Sprintf(`%#x`, event)}}
- }
-
return &jsonNotification{Version: jsonrpcVersion, Method: namespace + notificationMethodSuffix,
Params: jsonSubscription{Subscription: subid, Result: event}}
}
diff --git a/rpc/server.go b/rpc/server.go
index 2b7393dd2..8925419fe 100644
--- a/rpc/server.go
+++ b/rpc/server.go
@@ -313,7 +313,6 @@ func (s *Server) handle(ctx context.Context, codec ServerCodec, req *serverReque
if len(reply) == 0 {
return codec.CreateResponse(req.id, nil), nil
}
-
if req.callb.errPos >= 0 { // test if method returned an error
if !reply[req.callb.errPos].IsNil() {
e := reply[req.callb.errPos].Interface().(error)
diff --git a/rpc/utils.go b/rpc/utils.go
index 9315cab59..7f7ac4520 100644
--- a/rpc/utils.go
+++ b/rpc/utils.go
@@ -22,7 +22,6 @@ import (
crand "crypto/rand"
"encoding/binary"
"encoding/hex"
- "math/big"
"math/rand"
"reflect"
"strings"
@@ -105,20 +104,6 @@ func formatName(name string) string {
return string(ret)
}
-var bigIntType = reflect.TypeOf((*big.Int)(nil)).Elem()
-
-// Indication if this type should be serialized in hex
-func isHexNum(t reflect.Type) bool {
- if t == nil {
- return false
- }
- for t.Kind() == reflect.Ptr {
- t = t.Elem()
- }
-
- return t == bigIntType
-}
-
// suitableCallbacks iterates over the methods of the given type. It will determine if a method satisfies the criteria
// for a RPC callback or a subscription callback and adds it to the collection of callbacks or subscriptions. See server
// documentation for a summary of these criteria.