don't always spawn a goroutine for sending a new message

This commit is contained in:
vyzo 2018-01-13 20:11:32 +02:00
parent c95ed28496
commit 5ef13c764e

View File

@ -367,12 +367,14 @@ func (p *PubSub) pushMsg(subs []*Subscription, src peer.ID, msg *Message) {
return return
} }
go func() { sreq := sendReq{from: src, msg: msg}
p.sendMsg <- sendReq{ select {
from: src, case p.sendMsg <- sreq:
msg: msg, default:
} go func() {
}() p.sendMsg <- sreq
}()
}
} }
// validate performs validation and only sends the message if all validators succeed // validate performs validation and only sends the message if all validators succeed