Inline GossipSender.flush() and don't try to send nil

This commit is contained in:
Bryan Boreham committed 2015-06-10 12:18:09 +01:00
1 parent bd5353024f
commit 35b3a2d6a6
1 file changed
+8 -12
+8 -12
View File
@@ -63,7 +63,14 @@ func (sender *GossipSender) run() {
}
sender.send(pending)
case ch := <-sender.flushch:
sender.flush()
// ensure anything pending is sent, then close the channel we were given
select {
case pending := <-sender.cell:
if pending != nil {
sender.send(pending)
}
default:
}
close(ch)
}
}
@@ -341,14 +348,3 @@ func (router *Router) sendPendingGossip() {
<-ch
}
}
func (sender *GossipSender) flush() {
for {
select {
case pending := <-sender.cell:
sender.send(pending)
default:
return
}
}
}