From e3a8412df3fe75fe498a3fce64fd2fd691a18183 Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 8 Dec 2014 13:16:50 +0100 Subject: Proper start/stoping wpeers --- whisper/peer.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'whisper/peer.go') diff --git a/whisper/peer.go b/whisper/peer.go index 5fe50ba59..3471ddb2f 100644 --- a/whisper/peer.go +++ b/whisper/peer.go @@ -38,6 +38,13 @@ func (self *peer) init() error { func (self *peer) start() { go self.update() + self.peer.Infoln("whisper started") +} + +func (self *peer) stop() { + self.peer.Infoln("whisper stopped") + + close(self.quit) } func (self *peer) update() { @@ -69,9 +76,11 @@ func (self *peer) broadcast(envelopes []*Envelope) error { } } - msg := p2p.NewMsg(envelopesMsg, envs[:i]...) - if err := self.ws.WriteMsg(msg); err != nil { - return err + if i > 0 { + msg := p2p.NewMsg(envelopesMsg, envs[:i]...) + if err := self.ws.WriteMsg(msg); err != nil { + return err + } } return nil -- cgit