aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/args.go
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-03-26 18:59:16 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-03-26 18:59:16 +0800
commitad2089b0a3a495d8584209b6e31dde153cac7088 (patch)
tree5177a57636afbf8050be67bc7d62e963a383e9be /rpc/args.go
parent493e0d7be883bb1acd3b8588b0e3d641ce06c73b (diff)
downloaddexon-ad2089b0a3a495d8584209b6e31dde153cac7088.tar
dexon-ad2089b0a3a495d8584209b6e31dde153cac7088.tar.gz
dexon-ad2089b0a3a495d8584209b6e31dde153cac7088.tar.bz2
dexon-ad2089b0a3a495d8584209b6e31dde153cac7088.tar.lz
dexon-ad2089b0a3a495d8584209b6e31dde153cac7088.tar.xz
dexon-ad2089b0a3a495d8584209b6e31dde153cac7088.tar.zst
dexon-ad2089b0a3a495d8584209b6e31dde153cac7088.zip
Add blockHeightFromJson convenience function
Diffstat (limited to 'rpc/args.go')
-rw-r--r--rpc/args.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/rpc/args.go b/rpc/args.go
index 7504293a4..fc7307b83 100644
--- a/rpc/args.go
+++ b/rpc/args.go
@@ -8,7 +8,15 @@ import (
"github.com/ethereum/go-ethereum/common"
)
-func blockHeight(raw interface{}, number *int64) (err error) {
+func blockHeightFromJson(msg json.RawMessage, number *int64) error {
+ var raw interface{}
+ if err := json.Unmarshal(msg, &raw); err != nil {
+ return NewDecodeParamError(err.Error())
+ }
+ return blockHeight(raw, number)
+}
+
+func blockHeight(raw interface{}, number *int64) error {
// Parse as integer
num, ok := raw.(float64)
if ok {
@@ -19,7 +27,7 @@ func blockHeight(raw interface{}, number *int64) (err error) {
// Parse as string/hexstring
str, ok := raw.(string)
if !ok {
- return NewDecodeParamError("BlockNumber is not a string")
+ return NewDecodeParamError("BlockNumber is not a number or string")
}
switch str {