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)
|
||||
for _, peer := range p.peers {
|
||||
peer <- out
|
||||
for pid, peer := range p.peers {
|
||||
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
|
||||
// of a given message
|
||||
func (p *PubSub) subscribedToMsg(msg *pb.Message) bool {
|
||||
if len(p.myTopics) == 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, t := range msg.GetTopicIDs() {
|
||||
if _, ok := p.myTopics[t]; ok {
|
||||
return true
|
||||
|
|
Loading…
Reference in New Issue