diff options
author | obscuren <geffobscura@gmail.com> | 2015-02-17 21:19:05 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-02-17 21:19:05 +0800 |
commit | 547788b1b0c6a27c24ba3bc4362aa93143dfea2c (patch) | |
tree | eec78227e21d9846a2f33858d2214a32ec278da0 /rpc/args.go | |
parent | 2c454863f2f41fb232778a4cbd4cf135a58c4118 (diff) | |
download | dexon-547788b1b0c6a27c24ba3bc4362aa93143dfea2c.tar dexon-547788b1b0c6a27c24ba3bc4362aa93143dfea2c.tar.gz dexon-547788b1b0c6a27c24ba3bc4362aa93143dfea2c.tar.bz2 dexon-547788b1b0c6a27c24ba3bc4362aa93143dfea2c.tar.lz dexon-547788b1b0c6a27c24ba3bc4362aa93143dfea2c.tar.xz dexon-547788b1b0c6a27c24ba3bc4362aa93143dfea2c.tar.zst dexon-547788b1b0c6a27c24ba3bc4362aa93143dfea2c.zip |
Added optional address slice. Closes #326
Diffstat (limited to 'rpc/args.go')
-rw-r--r-- | rpc/args.go | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/rpc/args.go b/rpc/args.go index 12e3103bc..9c2c7d7a6 100644 --- a/rpc/args.go +++ b/rpc/args.go @@ -1,6 +1,7 @@ package rpc import "encoding/json" + import "github.com/ethereum/go-ethereum/core" type GetBlockArgs struct { @@ -203,7 +204,7 @@ func (obj *Sha3Args) UnmarshalJSON(b []byte) (err error) { type FilterOptions struct { Earliest int64 Latest int64 - Address string + Address interface{} Topic []string Skip int Max int @@ -211,9 +212,22 @@ type FilterOptions struct { func toFilterOptions(options *FilterOptions) core.FilterOptions { var opts core.FilterOptions + + // Convert optional address slice/string to byte slice + if str, ok := options.Address.(string); ok { + opts.Address = [][]byte{fromHex(str)} + } else if slice, ok := options.Address.([]interface{}); ok { + bslice := make([][]byte, len(slice)) + for i, addr := range slice { + if saddr, ok := addr.(string); ok { + bslice[i] = fromHex(saddr) + } + } + opts.Address = bslice + } + opts.Earliest = options.Earliest opts.Latest = options.Latest - opts.Address = fromHex(options.Address) opts.Topics = make([][]byte, len(options.Topic)) for i, topic := range options.Topic { opts.Topics[i] = fromHex(topic) |