From 63c977c8157a90c84a96b883a496b4a7ae96a9a0 Mon Sep 17 00:00:00 2001 From: Garrett Thornburg Date: Fri, 1 Sep 2017 21:16:41 -0400 Subject: [PATCH] Return false when we haven't subscribed to anything --- floodsub.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/floodsub.go b/floodsub.go index adefd5f..cb98445 100644 --- a/floodsub.go +++ b/floodsub.go @@ -259,6 +259,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