don't always spawn a goroutine for sending a new message
This commit is contained in:
parent
c95ed28496
commit
5ef13c764e
14
floodsub.go
14
floodsub.go
|
@ -367,12 +367,14 @@ func (p *PubSub) pushMsg(subs []*Subscription, src peer.ID, msg *Message) {
|
|||
return
|
||||
}
|
||||
|
||||
go func() {
|
||||
p.sendMsg <- sendReq{
|
||||
from: src,
|
||||
msg: msg,
|
||||
}
|
||||
}()
|
||||
sreq := sendReq{from: src, msg: msg}
|
||||
select {
|
||||
case p.sendMsg <- sreq:
|
||||
default:
|
||||
go func() {
|
||||
p.sendMsg <- sreq
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
// validate performs validation and only sends the message if all validators succeed
|
||||
|
|
Loading…
Reference in New Issue