mirror of
https://github.com/logos-messaging/go-libp2p-pubsub.git
synced 2026-01-08 07:43:11 +00:00
Merge pull request #35 from film42/gt/slow_announce
Drop announce messages to slow peers
This commit is contained in:
commit
d884976a41
12
floodsub.go
12
floodsub.go
@ -230,8 +230,12 @@ func (p *PubSub) announce(topic string, sub bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
out := rpcWithSubs(subopt)
|
out := rpcWithSubs(subopt)
|
||||||
for _, peer := range p.peers {
|
for pid, peer := range p.peers {
|
||||||
peer <- out
|
select {
|
||||||
|
case peer <- out:
|
||||||
|
default:
|
||||||
|
log.Infof("dropping announce message to peer %s: queue full", pid)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,6 +263,10 @@ func (p *PubSub) markSeen(id string) {
|
|||||||
// subscribedToMessage returns whether we are subscribed to one of the topics
|
// subscribedToMessage returns whether we are subscribed to one of the topics
|
||||||
// of a given message
|
// of a given message
|
||||||
func (p *PubSub) subscribedToMsg(msg *pb.Message) bool {
|
func (p *PubSub) subscribedToMsg(msg *pb.Message) bool {
|
||||||
|
if len(p.myTopics) == 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
for _, t := range msg.GetTopicIDs() {
|
for _, t := range msg.GetTopicIDs() {
|
||||||
if _, ok := p.myTopics[t]; ok {
|
if _, ok := p.myTopics[t]; ok {
|
||||||
return true
|
return true
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user