Skip to content

Commit

Permalink
Added optional address slice. Closes #326
Browse files Browse the repository at this point in the history
  • Loading branch information
obscuren committed Feb 17, 2015
1 parent 2c45486 commit 547788b
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions rpc/args.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package rpc

import "encoding/json"

import "github.com/ethereum/go-ethereum/core"

type GetBlockArgs struct {
Expand Down Expand Up @@ -203,17 +204,30 @@ 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
}

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)
Expand Down

0 comments on commit 547788b

Please sign in to comment.