diff options
author | Péter Szilágyi <peterke@gmail.com> | 2015-04-14 20:02:31 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2015-04-14 20:02:31 +0800 |
commit | 1a4cfc173eb3f62c5859d25744f3c0de119e1b59 (patch) | |
tree | b9bb63e04f872e4afa2bed3e25d23d7b5cdbc397 /whisper | |
parent | e2b7498c9dca34a1ebe29ba2eb6d5e1e2b48df5a (diff) | |
download | dexon-1a4cfc173eb3f62c5859d25744f3c0de119e1b59.tar.gz dexon-1a4cfc173eb3f62c5859d25744f3c0de119e1b59.tar.zst dexon-1a4cfc173eb3f62c5859d25744f3c0de119e1b59.zip |
whisper, xeth/whisper, ui/qt/qwhispe: fix API polish breakages
Diffstat (limited to 'whisper')
-rw-r--r-- | whisper/whisper.go | 31 |
1 files changed, 15 insertions, 16 deletions
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 { |