diff options
author | obscuren <geffobscura@gmail.com> | 2015-01-13 20:36:44 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-01-13 20:36:44 +0800 |
commit | e3cad04decbbc83a0c956850717cb0ae0b2b3eec (patch) | |
tree | 81e0f1a57344a7c0d6a2ae2f1481c2e26880d1c2 /ui/qt | |
parent | 1e5353824a7859d5cfa98565b5a879d5ca7e582a (diff) | |
download | dexon-e3cad04decbbc83a0c956850717cb0ae0b2b3eec.tar.gz dexon-e3cad04decbbc83a0c956850717cb0ae0b2b3eec.tar.zst dexon-e3cad04decbbc83a0c956850717cb0ae0b2b3eec.zip |
Fixed whisper messages
* Whisper protocol wasn't properly suppling envelope slices
* Message history wasn't properly propagated
* Added 'Messages' method, filtering any current envelope with the
supplied filter.
Diffstat (limited to 'ui/qt')
-rw-r--r-- | ui/qt/qwhisper/message.go | 6 | ||||
-rw-r--r-- | ui/qt/qwhisper/whisper.go | 12 |
2 files changed, 12 insertions, 6 deletions
diff --git a/ui/qt/qwhisper/message.go b/ui/qt/qwhisper/message.go index c87647399..3a80381ff 100644 --- a/ui/qt/qwhisper/message.go +++ b/ui/qt/qwhisper/message.go @@ -8,9 +8,9 @@ import ( type Message struct { ref *whisper.Message - Flags int32 - Payload string - From string + Flags int32 `json:"flags"` + Payload string `json:"payload"` + From string `json:"from"` } func ToQMessage(msg *whisper.Message) *Message { diff --git a/ui/qt/qwhisper/whisper.go b/ui/qt/qwhisper/whisper.go index becb2a29b..b904678f4 100644 --- a/ui/qt/qwhisper/whisper.go +++ b/ui/qt/qwhisper/whisper.go @@ -43,7 +43,7 @@ func (self *Whisper) Post(payload []string, to, from string, topics []string, pr msg := whisper.NewMessage(data) envelope, err := msg.Seal(time.Duration(priority*100000), whisper.Opts{ - Ttl: time.Duration(ttl), + Ttl: time.Duration(ttl) * time.Second, To: crypto.ToECDSAPub(fromHex(to)), From: crypto.ToECDSA(fromHex(from)), Topics: whisper.TopicsFromString(topics...), @@ -84,8 +84,14 @@ func (self *Whisper) Watch(opts map[string]interface{}, view *qml.Common) int { return i } -func (self *Whisper) Trigger(id int) { - go self.Whisper.Trigger(id) +func (self *Whisper) Messages(id int) (messages *ethutil.List) { + msgs := self.Whisper.Messages(id) + messages = ethutil.EmptyList() + for _, message := range msgs { + messages.Append(ToQMessage(message)) + } + + return } func filterFromMap(opts map[string]interface{}) (f whisper.Filter) { |