aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ui/qt/qwhisper/whisper.go4
-rw-r--r--whisper/whisper.go31
-rw-r--r--xeth/whisper.go4
3 files changed, 19 insertions, 20 deletions
diff --git a/ui/qt/qwhisper/whisper.go b/ui/qt/qwhisper/whisper.go
index 3c2d0a4b9..50b0626f5 100644
--- a/ui/qt/qwhisper/whisper.go
+++ b/ui/qt/qwhisper/whisper.go
@@ -41,7 +41,7 @@ func (self *Whisper) Post(payload []string, to, from string, topics []string, pr
TTL: time.Duration(ttl) * time.Second,
To: crypto.ToECDSAPub(common.FromHex(to)),
From: key,
- Topics: whisper.TopicsFromString(topics...),
+ Topics: whisper.NewTopicsFromStrings(topics...),
})
if err != nil {
@@ -106,7 +106,7 @@ func filterFromMap(opts map[string]interface{}) (f whisper.Filter) {
if topicList, ok := opts["topics"].(*qml.List); ok {
var topics []string
topicList.Convert(&topics)
- f.Topics = whisper.TopicsFromString(topics...)
+ f.Topics = whisper.NewTopicsFromStrings(topics...)
}
return
diff --git a/whisper/whisper.go b/whisper/whisper.go
index e56c45786..2634a23a4 100644
--- a/whisper/whisper.go
+++ b/whisper/whisper.go
@@ -144,6 +144,21 @@ func (self *Whisper) Stop() {
glog.V(logger.Info).Infoln("Whisper stopped")
}
+// Messages retrieves the currently pooled messages matching a filter id.
+func (self *Whisper) Messages(id int) []*Message {
+ messages := make([]*Message, 0)
+ if filter := self.filters.Get(id); filter != nil {
+ for _, envelope := range self.messages {
+ if message := self.open(envelope); message != nil {
+ if self.filters.Match(filter, createFilter(message, envelope.Topics)) {
+ messages = append(messages, message)
+ }
+ }
+ }
+ }
+ return messages
+}
+
// func (self *Whisper) RemoveIdentity(key *ecdsa.PublicKey) bool {
// k := string(crypto.FromECDSAPub(key))
// if _, ok := self.keys[k]; ok {
@@ -153,22 +168,6 @@ func (self *Whisper) Stop() {
// return false
// }
-/*func (self *Whisper) Messages(id int) (messages []*Message) {
- filter := self.filters.Get(id)
- if filter != nil {
- for _, e := range self.messages {
- if msg := self.open(e); msg != nil {
- f := createFilter(msg, e.Topics)
- if self.filters.Match(filter, f) {
- messages = append(messages, msg)
- }
- }
- }
- }
-
- return
-}*/
-
// handlePeer is called by the underlying P2P layer when the whisper sub-protocol
// connection is negotiated.
func (self *Whisper) handlePeer(peer *p2p.Peer, rw p2p.MsgReadWriter) error {
diff --git a/xeth/whisper.go b/xeth/whisper.go
index 51caec8d6..342910b5c 100644
--- a/xeth/whisper.go
+++ b/xeth/whisper.go
@@ -36,7 +36,7 @@ func (self *Whisper) Post(payload string, to, from string, topics []string, prio
TTL: time.Duration(ttl) * time.Second,
To: crypto.ToECDSAPub(common.FromHex(to)),
From: key,
- Topics: whisper.TopicsFromString(topics...),
+ Topics: whisper.NewTopicsFromStrings(topics...),
})
if err != nil {
@@ -71,7 +71,7 @@ func (self *Whisper) Watch(opts *Options) int {
filter := whisper.Filter{
To: crypto.ToECDSAPub(common.FromHex(opts.To)),
From: crypto.ToECDSAPub(common.FromHex(opts.From)),
- Topics: whisper.TopicsFromString(opts.Topics...),
+ Topics: whisper.NewTopicsFromStrings(opts.Topics...),
}
var i int