diff options
author | obscuren <geffobscura@gmail.com> | 2014-12-17 02:55:57 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-12-17 02:55:57 +0800 |
commit | 52b54631a47dfa46742635be178f2f8d33dd9f41 (patch) | |
tree | 5d99624cd5df30c9747039dd874559a974af9bdd /event | |
parent | 93edae280d60d217084430a0c6c16f648c82732e (diff) | |
download | dexon-52b54631a47dfa46742635be178f2f8d33dd9f41.tar dexon-52b54631a47dfa46742635be178f2f8d33dd9f41.tar.gz dexon-52b54631a47dfa46742635be178f2f8d33dd9f41.tar.bz2 dexon-52b54631a47dfa46742635be178f2f8d33dd9f41.tar.lz dexon-52b54631a47dfa46742635be178f2f8d33dd9f41.tar.xz dexon-52b54631a47dfa46742635be178f2f8d33dd9f41.tar.zst dexon-52b54631a47dfa46742635be178f2f8d33dd9f41.zip |
Whisper watches fixes
Diffstat (limited to 'event')
-rw-r--r-- | event/filter/generic_filter.go | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/event/filter/generic_filter.go b/event/filter/generic_filter.go index b04b4801e..2ce0f0642 100644 --- a/event/filter/generic_filter.go +++ b/event/filter/generic_filter.go @@ -2,19 +2,29 @@ package filter type Generic struct { Str1, Str2, Str3 string + Data map[string]struct{} Fn func(data interface{}) } +// self = registered, f = incoming func (self Generic) Compare(f Filter) bool { + var strMatch, dataMatch = true, true + filter := f.(Generic) - if (len(self.Str1) == 0 || filter.Str1 == self.Str1) && - (len(self.Str2) == 0 || filter.Str2 == self.Str2) && - (len(self.Str3) == 0 || filter.Str3 == self.Str3) { - return true + if (len(self.Str1) > 0 && filter.Str1 != self.Str1) || + (len(self.Str2) > 0 && filter.Str2 != self.Str2) || + (len(self.Str3) > 0 && filter.Str3 != self.Str3) { + strMatch = false + } + + for k, _ := range self.Data { + if _, ok := filter.Data[k]; !ok { + return false + } } - return false + return strMatch && dataMatch } func (self Generic) Trigger(data interface{}) { |