Filter accepts multiple topics per entry. Fixes #403

This commit is contained in:
obscuren
2015-03-01 19:08:26 +01:00
parent ac88ae86a3
commit 6e50a1e9f5
4 changed files with 40 additions and 104 deletions

View File

@ -197,7 +197,7 @@ type FilterOptions struct {
Earliest int64
Latest int64
Address interface{}
Topic []string
Topic []interface{}
Skip int
Max int
}
@ -220,10 +220,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.Topic))
for i, topicDat := range options.Topic {
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
}