From ad2089b0a3a495d8584209b6e31dde153cac7088 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Thu, 26 Mar 2015 11:59:16 +0100 Subject: Add blockHeightFromJson convenience function --- rpc/args.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'rpc') 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 { -- cgit