Return error when filter params are not strings

pull/522/head
Taylor Gerring 10 years ago
parent 03ac0f18ae
commit 719effa7ec
  1. 24
      rpc/args.go

@ -359,24 +359,30 @@ func (args *FilterOptions) UnmarshalJSON(b []byte) (err error) {
} }
fromstr, ok := obj[0].FromBlock.(string) fromstr, ok := obj[0].FromBlock.(string)
if ok { if !ok {
if fromstr == "latest" { return NewDecodeParamError("FromBlock is not a string")
}
switch fromstr {
case "latest":
args.Earliest = 0 args.Earliest = 0
} else { default:
args.Earliest = int64(common.Big(obj[0].FromBlock.(string)).Int64()) args.Earliest = int64(common.Big(obj[0].FromBlock.(string)).Int64())
} }
}
tostr, ok := obj[0].ToBlock.(string) tostr, ok := obj[0].ToBlock.(string)
if ok { if !ok {
if tostr == "latest" { return NewDecodeParamError("ToBlock is not a string")
}
switch tostr {
case "latest":
args.Latest = 0 args.Latest = 0
} else if tostr == "pending" { case "pending":
args.Latest = -1 args.Latest = -1
} else { default:
args.Latest = int64(common.Big(obj[0].ToBlock.(string)).Int64()) args.Latest = int64(common.Big(obj[0].ToBlock.(string)).Int64())
} }
}
args.Max = int(common.Big(obj[0].Limit).Int64()) args.Max = int(common.Big(obj[0].Limit).Int64())
args.Skip = int(common.Big(obj[0].Offset).Int64()) args.Skip = int(common.Big(obj[0].Offset).Int64())

Loading…
Cancel
Save