aboutsummaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-01-28 00:01:30 +0800
committerPéter Szilágyi <peterke@gmail.com>2016-02-03 16:35:59 +0800
commit5da7ec7c18b0e37cec0950e9656f6cdddc1ae60c (patch)
treeae78c0511eaead00800acc268d2782cb2ceef9b0 /rpc
parenta8fd0de0d344ce3828901fa47204a68971184684 (diff)
downloadgo-tangerine-5da7ec7c18b0e37cec0950e9656f6cdddc1ae60c.tar
go-tangerine-5da7ec7c18b0e37cec0950e9656f6cdddc1ae60c.tar.gz
go-tangerine-5da7ec7c18b0e37cec0950e9656f6cdddc1ae60c.tar.bz2
go-tangerine-5da7ec7c18b0e37cec0950e9656f6cdddc1ae60c.tar.lz
go-tangerine-5da7ec7c18b0e37cec0950e9656f6cdddc1ae60c.tar.xz
go-tangerine-5da7ec7c18b0e37cec0950e9656f6cdddc1ae60c.tar.zst
go-tangerine-5da7ec7c18b0e37cec0950e9656f6cdddc1ae60c.zip
cmd, eth, rpc: fix some RPC issues with pending blocks
Diffstat (limited to 'rpc')
-rw-r--r--rpc/server.go2
-rw-r--r--rpc/types.go13
2 files changed, 7 insertions, 8 deletions
diff --git a/rpc/server.go b/rpc/server.go
index 0b93a4e64..5b88d843a 100644
--- a/rpc/server.go
+++ b/rpc/server.go
@@ -332,7 +332,6 @@ func (s *Server) handle(ctx context.Context, codec ServerCodec, req *serverReque
return res
}
}
-
return codec.CreateResponse(req.id, reply[0].Interface())
}
@@ -344,7 +343,6 @@ func (s *Server) exec(ctx context.Context, codec ServerCodec, req *serverRequest
} else {
response = s.handle(ctx, codec, req)
}
-
if err := codec.Write(response); err != nil {
glog.V(logger.Error).Infof("%v\n", err)
codec.Close()
diff --git a/rpc/types.go b/rpc/types.go
index 02295a022..f268d84db 100644
--- a/rpc/types.go
+++ b/rpc/types.go
@@ -174,12 +174,14 @@ type HexNumber big.Int
// NewHexNumber creates a new hex number instance which will serialize the given val with `%#x` on marshal.
func NewHexNumber(val interface{}) *HexNumber {
if val == nil {
- return nil
+ return nil // note, this doesn't catch nil pointers, only passing nil directly!
}
- if v, ok := val.(*big.Int); ok && v != nil {
- hn := new(big.Int).Set(v)
- return (*HexNumber)(hn)
+ if v, ok := val.(*big.Int); ok {
+ if v != nil {
+ return (*HexNumber)(new(big.Int).Set(v))
+ }
+ return nil
}
rval := reflect.ValueOf(val)
@@ -303,10 +305,9 @@ const (
)
// UnmarshalJSON parses the given JSON fragement into a BlockNumber. It supports:
-// - "latest" or "earliest" as string arguments
+// - "latest", "earliest" or "pending" as string arguments
// - the block number
// Returned errors:
-// - an unsupported error when "pending" is specified (not yet implemented)
// - an invalid block number error when the given argument isn't a known strings
// - an out of range error when the given block number is either too little or too large
func (bn *BlockNumber) UnmarshalJSON(data []byte) error {