From a7538d0020d3a51ab3b25997b3c4f01db87d4c7a Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 9 Mar 2015 18:19:35 +0100 Subject: [PATCH] merge --- rpc/api.go | 16 +++++++++++++--- rpc/args.go | 17 ++--------------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/rpc/api.go b/rpc/api.go index 617e4998d..dc0945d19 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -665,10 +665,20 @@ func toFilterOptions(options *FilterOptions) core.FilterOptions { opts.Earliest = options.Earliest opts.Latest = options.Latest - opts.Topics = make([][][]byte, len(options.Topic)) - for i, topic := range options.Topic { - opts.Topics[i] = fromHex(topic) + + topics := make([][][]byte, len(options.Topics)) + for i, topicDat := range options.Topics { + if slice, ok := topicDat.([]interface{}); ok { + topics[i] = make([][]byte, len(slice)) + for j, topic := range slice { + topics[i][j] = fromHex(topic.(string)) + } + } else if str, ok := topicDat.(string); ok { + topics[i] = make([][]byte, 1) + topics[i][0] = fromHex(str) + } } + opts.Topics = topics return opts } diff --git a/rpc/args.go b/rpc/args.go index d34cfb2fa..63969e598 100644 --- a/rpc/args.go +++ b/rpc/args.go @@ -333,7 +333,7 @@ type FilterOptions struct { Earliest int64 Latest int64 Address interface{} - Topic []interface{} + Topics []interface{} Skip int Max int } @@ -360,20 +360,7 @@ func (args *FilterOptions) UnmarshalJSON(b []byte) (err error) { args.Max = int(ethutil.Big(obj[0].Limit).Int64()) args.Skip = int(ethutil.Big(obj[0].Offset).Int64()) args.Address = obj[0].Address - - topics := make([][][]byte, len(obj[0].Topics)) - for i, topicDat := range obj[0].Topics { - if slice, ok := topicDat.([]interface{}); ok { - topics[i] = make([][]byte, len(slice)) - for j, topic := range slice { - topics[i][j] = fromHex(topic.(string)) - } - } else if str, ok := topicDat.(string); ok { - topics[i] = make([][]byte, 1) - topics[i][0] = fromHex(str) - } - } - args.Topics = topics + args.Topics = obj[0].Topics return nil }