diff options
author | Taylor Gerring <taylor.gerring@gmail.com> | 2015-03-27 03:52:09 +0800 |
---|---|---|
committer | Taylor Gerring <taylor.gerring@gmail.com> | 2015-03-27 03:52:09 +0800 |
commit | 9ca87afd0ba043043a3d2b4919d72b7f7a39ffe8 (patch) | |
tree | e15cd955e22f97a2094086c1d98c5e270f65f5f8 /rpc/args.go | |
parent | 81f36df910533de63dc5ac66f38b5481961cc0c8 (diff) | |
download | dexon-9ca87afd0ba043043a3d2b4919d72b7f7a39ffe8.tar dexon-9ca87afd0ba043043a3d2b4919d72b7f7a39ffe8.tar.gz dexon-9ca87afd0ba043043a3d2b4919d72b7f7a39ffe8.tar.bz2 dexon-9ca87afd0ba043043a3d2b4919d72b7f7a39ffe8.tar.lz dexon-9ca87afd0ba043043a3d2b4919d72b7f7a39ffe8.tar.xz dexon-9ca87afd0ba043043a3d2b4919d72b7f7a39ffe8.tar.zst dexon-9ca87afd0ba043043a3d2b4919d72b7f7a39ffe8.zip |
WhisperFilterArgs
Diffstat (limited to 'rpc/args.go')
-rw-r--r-- | rpc/args.go | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/rpc/args.go b/rpc/args.go index 0169ece58..5ad971ced 100644 --- a/rpc/args.go +++ b/rpc/args.go @@ -720,9 +720,8 @@ type WhisperFilterArgs struct { func (args *WhisperFilterArgs) UnmarshalJSON(b []byte) (err error) { var obj []struct { - To string - From string - Topics []string + To interface{} + Topics []interface{} } if err = json.Unmarshal(b, &obj); err != nil { @@ -733,9 +732,22 @@ func (args *WhisperFilterArgs) UnmarshalJSON(b []byte) (err error) { return NewInsufficientParamsError(len(obj), 1) } - args.To = obj[0].To - args.From = obj[0].From - args.Topics = obj[0].Topics + var argstr string + argstr, ok := obj[0].To.(string) + if !ok { + return NewInvalidTypeError("to", "is not a string") + } + args.To = argstr + + t := make([]string, len(obj[0].Topics)) + for i, j := range obj[0].Topics { + argstr, ok := j.(string) + if !ok { + return NewInvalidTypeError("topics["+string(i)+"]", "is not a string") + } + t[i] = argstr + } + args.Topics = t return nil } |