aboutsummaryrefslogtreecommitdiffstats
path: root/whisper/peer.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-12-08 20:16:50 +0800
committerobscuren <geffobscura@gmail.com>2014-12-08 20:16:50 +0800
commite3a8412df3fe75fe498a3fce64fd2fd691a18183 (patch)
tree7c2e88be6b9d7dec5180a508a387b24835928022 /whisper/peer.go
parentebe2d9d872c5482e02508f1d3e9c3a56e8a41d44 (diff)
downloadgo-tangerine-e3a8412df3fe75fe498a3fce64fd2fd691a18183.tar
go-tangerine-e3a8412df3fe75fe498a3fce64fd2fd691a18183.tar.gz
go-tangerine-e3a8412df3fe75fe498a3fce64fd2fd691a18183.tar.bz2
go-tangerine-e3a8412df3fe75fe498a3fce64fd2fd691a18183.tar.lz
go-tangerine-e3a8412df3fe75fe498a3fce64fd2fd691a18183.tar.xz
go-tangerine-e3a8412df3fe75fe498a3fce64fd2fd691a18183.tar.zst
go-tangerine-e3a8412df3fe75fe498a3fce64fd2fd691a18183.zip
Proper start/stoping wpeers
Diffstat (limited to 'whisper/peer.go')
-rw-r--r--whisper/peer.go15
1 files changed, 12 insertions, 3 deletions
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