diff options
author | Péter Szilágyi <peterke@gmail.com> | 2015-04-21 23:31:08 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2015-04-28 15:49:04 +0800 |
commit | ae4bfc3cfb3f1debad9dd0211950ce09038ffa90 (patch) | |
tree | d09f6c0291eab1b02cc1145b816542024e7c4bfa /whisper/whisper.go | |
parent | 15586368e52f49a0f7ea28f890af49d196760846 (diff) | |
download | dexon-ae4bfc3cfb3f1debad9dd0211950ce09038ffa90.tar dexon-ae4bfc3cfb3f1debad9dd0211950ce09038ffa90.tar.gz dexon-ae4bfc3cfb3f1debad9dd0211950ce09038ffa90.tar.bz2 dexon-ae4bfc3cfb3f1debad9dd0211950ce09038ffa90.tar.lz dexon-ae4bfc3cfb3f1debad9dd0211950ce09038ffa90.tar.xz dexon-ae4bfc3cfb3f1debad9dd0211950ce09038ffa90.tar.zst dexon-ae4bfc3cfb3f1debad9dd0211950ce09038ffa90.zip |
rpc, ui/qt/qwhisper, whisper, xeth: introduce complex topic filters
Diffstat (limited to 'whisper/whisper.go')
-rw-r--r-- | whisper/whisper.go | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/whisper/whisper.go b/whisper/whisper.go index 61999f07a..5d6ee6e3b 100644 --- a/whisper/whisper.go +++ b/whisper/whisper.go @@ -118,11 +118,11 @@ func (self *Whisper) GetIdentity(key *ecdsa.PublicKey) *ecdsa.PrivateKey { // Watch installs a new message handler to run in case a matching packet arrives // from the whisper network. func (self *Whisper) Watch(options Filter) int { - filter := filter.Generic{ - Str1: string(crypto.FromECDSAPub(options.To)), - Str2: string(crypto.FromECDSAPub(options.From)), - Data: newTopicSet(options.Topics), - Fn: func(data interface{}) { + filter := filterer{ + to: string(crypto.FromECDSAPub(options.To)), + from: string(crypto.FromECDSAPub(options.From)), + matcher: newTopicMatcher(options.Topics...), + fn: func(data interface{}) { options.Fn(data.(*Message)) }, } @@ -273,10 +273,14 @@ func (self *Whisper) open(envelope *Envelope) *Message { // createFilter creates a message filter to check against installed handlers. func createFilter(message *Message, topics []Topic) filter.Filter { - return filter.Generic{ - Str1: string(crypto.FromECDSAPub(message.To)), - Str2: string(crypto.FromECDSAPub(message.Recover())), - Data: newTopicSet(topics), + matcher := make([][]Topic, len(topics)) + for i, topic := range topics { + matcher[i] = []Topic{topic} + } + return filterer{ + to: string(crypto.FromECDSAPub(message.To)), + from: string(crypto.FromECDSAPub(message.Recover())), + matcher: newTopicMatcher(matcher...), } } |