diff options
author | Péter Szilágyi <peterke@gmail.com> | 2015-04-22 17:50:48 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2015-04-28 15:49:04 +0800 |
commit | db615a85ec000dab7f73a6d4b1b46428ba4acdee (patch) | |
tree | 0ffc36dae8454fcbdcde7fa0d1e616365e87ad29 /whisper/topic.go | |
parent | ae4bfc3cfb3f1debad9dd0211950ce09038ffa90 (diff) | |
download | dexon-db615a85ec000dab7f73a6d4b1b46428ba4acdee.tar dexon-db615a85ec000dab7f73a6d4b1b46428ba4acdee.tar.gz dexon-db615a85ec000dab7f73a6d4b1b46428ba4acdee.tar.bz2 dexon-db615a85ec000dab7f73a6d4b1b46428ba4acdee.tar.lz dexon-db615a85ec000dab7f73a6d4b1b46428ba4acdee.tar.xz dexon-db615a85ec000dab7f73a6d4b1b46428ba4acdee.tar.zst dexon-db615a85ec000dab7f73a6d4b1b46428ba4acdee.zip |
ui/qt/qwhisper, whisper, xeth: polish topic filter, fix wildcards
Diffstat (limited to 'whisper/topic.go')
-rw-r--r-- | whisper/topic.go | 42 |
1 files changed, 2 insertions, 40 deletions
diff --git a/whisper/topic.go b/whisper/topic.go index b2a264e29..c47c94ae1 100644 --- a/whisper/topic.go +++ b/whisper/topic.go @@ -11,6 +11,8 @@ import "github.com/ethereum/go-ethereum/crypto" type Topic [4]byte // NewTopic creates a topic from the 4 byte prefix of the SHA3 hash of the data. +// +// Note, empty topics are considered the wildcard, and cannot be used in messages. func NewTopic(data []byte) Topic { prefix := [4]byte{} copy(prefix[:], crypto.Sha3(data)[:4]) @@ -27,26 +29,6 @@ func NewTopics(data ...[]byte) []Topic { return topics } -// NewTopicFilter creates a 2D topic array used by whisper.Filter from binary -// data elements. -func NewTopicFilter(data ...[][]byte) [][]Topic { - filter := make([][]Topic, len(data)) - for i, condition := range data { - filter[i] = NewTopics(condition...) - } - return filter -} - -// NewTopicFilterFlat creates a 2D topic array used by whisper.Filter from flat -// binary data elements. -func NewTopicFilterFlat(data ...[]byte) [][]Topic { - filter := make([][]Topic, len(data)) - for i, element := range data { - filter[i] = []Topic{NewTopic(element)} - } - return filter -} - // NewTopicFromString creates a topic using the binary data contents of the // specified string. func NewTopicFromString(data string) Topic { @@ -63,26 +45,6 @@ func NewTopicsFromStrings(data ...string) []Topic { return topics } -// NewTopicFilterFromStrings creates a 2D topic array used by whisper.Filter -// from textual data elements. -func NewTopicFilterFromStrings(data ...[]string) [][]Topic { - filter := make([][]Topic, len(data)) - for i, condition := range data { - filter[i] = NewTopicsFromStrings(condition...) - } - return filter -} - -// NewTopicFilterFromStringsFlat creates a 2D topic array used by whisper.Filter from flat -// binary data elements. -func NewTopicFilterFromStringsFlat(data ...string) [][]Topic { - filter := make([][]Topic, len(data)) - for i, element := range data { - filter[i] = []Topic{NewTopicFromString(element)} - } - return filter -} - // String converts a topic byte array to a string representation. func (self *Topic) String() string { return string(self[:]) |