diff options
Diffstat (limited to 'whisper/whisperv5/filter.go')
-rw-r--r-- | whisper/whisperv5/filter.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/whisper/whisperv5/filter.go b/whisper/whisperv5/filter.go index d571160d7..b5e893e0f 100644 --- a/whisper/whisperv5/filter.go +++ b/whisper/whisperv5/filter.go @@ -22,6 +22,7 @@ import ( "sync" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" ) @@ -68,6 +69,10 @@ func (fs *Filters) Install(watcher *Filter) (string, error) { return "", fmt.Errorf("failed to generate unique ID") } + if watcher.expectsSymmetricEncryption() { + watcher.SymKeyHash = crypto.Keccak256Hash(watcher.KeySym) + } + fs.watchers[id] = watcher return id, err } @@ -119,7 +124,9 @@ func (fs *Filters) NotifyWatchers(env *Envelope, p2pMessage bool) { if match && msg != nil { log.Trace("processing message: decrypted", "hash", env.Hash().Hex()) - watcher.Trigger(msg) + if watcher.Src == nil || IsPubKeyEqual(msg.Src, watcher.Src) { + watcher.Trigger(msg) + } } } } @@ -172,9 +179,6 @@ func (f *Filter) MatchMessage(msg *ReceivedMessage) bool { if f.PoW > 0 && msg.PoW < f.PoW { return false } - if f.Src != nil && !IsPubKeyEqual(msg.Src, f.Src) { - return false - } if f.expectsAsymmetricEncryption() && msg.isAsymmetricEncryption() { return IsPubKeyEqual(&f.KeyAsym.PublicKey, msg.Dst) && f.MatchTopic(msg.Topic) |