diff options
author | Taylor Gerring <taylor.gerring@gmail.com> | 2015-03-17 03:30:31 +0800 |
---|---|---|
committer | Taylor Gerring <taylor.gerring@gmail.com> | 2015-03-17 03:30:31 +0800 |
commit | 719effa7ecdef925a5a8fa61ac060e2ec5f0d612 (patch) | |
tree | 6fc325671e61d431ba0fdb17a0bfdff795681e8c /rpc | |
parent | 03ac0f18ae8bcc9c2f843841b8fe322717616a21 (diff) | |
download | dexon-719effa7ecdef925a5a8fa61ac060e2ec5f0d612.tar dexon-719effa7ecdef925a5a8fa61ac060e2ec5f0d612.tar.gz dexon-719effa7ecdef925a5a8fa61ac060e2ec5f0d612.tar.bz2 dexon-719effa7ecdef925a5a8fa61ac060e2ec5f0d612.tar.lz dexon-719effa7ecdef925a5a8fa61ac060e2ec5f0d612.tar.xz dexon-719effa7ecdef925a5a8fa61ac060e2ec5f0d612.tar.zst dexon-719effa7ecdef925a5a8fa61ac060e2ec5f0d612.zip |
Return error when filter params are not strings
Diffstat (limited to 'rpc')
-rw-r--r-- | rpc/args.go | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/rpc/args.go b/rpc/args.go index 9ec2ed8a4..fee44c4e0 100644 --- a/rpc/args.go +++ b/rpc/args.go @@ -359,23 +359,29 @@ func (args *FilterOptions) UnmarshalJSON(b []byte) (err error) { } fromstr, ok := obj[0].FromBlock.(string) - if ok { - if fromstr == "latest" { - args.Earliest = 0 - } else { - args.Earliest = int64(common.Big(obj[0].FromBlock.(string)).Int64()) - } + if !ok { + return NewDecodeParamError("FromBlock is not a string") + } + + switch fromstr { + case "latest": + args.Earliest = 0 + default: + args.Earliest = int64(common.Big(obj[0].FromBlock.(string)).Int64()) } tostr, ok := obj[0].ToBlock.(string) - if ok { - if tostr == "latest" { - args.Latest = 0 - } else if tostr == "pending" { - args.Latest = -1 - } else { - args.Latest = int64(common.Big(obj[0].ToBlock.(string)).Int64()) - } + if !ok { + return NewDecodeParamError("ToBlock is not a string") + } + + switch tostr { + case "latest": + args.Latest = 0 + case "pending": + args.Latest = -1 + default: + args.Latest = int64(common.Big(obj[0].ToBlock.(string)).Int64()) } args.Max = int(common.Big(obj[0].Limit).Int64()) |