forked from cerc-io/plugeth
Added optional address slice. Closes #326
This commit is contained in:
parent
2c454863f2
commit
547788b1b0
18
rpc/args.go
18
rpc/args.go
@ -1,6 +1,7 @@
|
|||||||
package rpc
|
package rpc
|
||||||
|
|
||||||
import "encoding/json"
|
import "encoding/json"
|
||||||
|
|
||||||
import "github.com/ethereum/go-ethereum/core"
|
import "github.com/ethereum/go-ethereum/core"
|
||||||
|
|
||||||
type GetBlockArgs struct {
|
type GetBlockArgs struct {
|
||||||
@ -203,7 +204,7 @@ func (obj *Sha3Args) UnmarshalJSON(b []byte) (err error) {
|
|||||||
type FilterOptions struct {
|
type FilterOptions struct {
|
||||||
Earliest int64
|
Earliest int64
|
||||||
Latest int64
|
Latest int64
|
||||||
Address string
|
Address interface{}
|
||||||
Topic []string
|
Topic []string
|
||||||
Skip int
|
Skip int
|
||||||
Max int
|
Max int
|
||||||
@ -211,9 +212,22 @@ type FilterOptions struct {
|
|||||||
|
|
||||||
func toFilterOptions(options *FilterOptions) core.FilterOptions {
|
func toFilterOptions(options *FilterOptions) core.FilterOptions {
|
||||||
var opts 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.Earliest = options.Earliest
|
||||||
opts.Latest = options.Latest
|
opts.Latest = options.Latest
|
||||||
opts.Address = fromHex(options.Address)
|
|
||||||
opts.Topics = make([][]byte, len(options.Topic))
|
opts.Topics = make([][]byte, len(options.Topic))
|
||||||
for i, topic := range options.Topic {
|
for i, topic := range options.Topic {
|
||||||
opts.Topics[i] = fromHex(topic)
|
opts.Topics[i] = fromHex(topic)
|
||||||
|
Loading…
Reference in New Issue
Block a user