From ce3da3facd5ce3c3bdd656ac8279dcf92fff1e5c Mon Sep 17 00:00:00 2001 From: vyzo Date: Fri, 27 Mar 2020 20:56:03 +0200 Subject: [PATCH] move self-publish check to pubsub --- gossipsub.go | 8 +------- pubsub.go | 6 ++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gossipsub.go b/gossipsub.go index bdf7aca..088ab95 100644 --- a/gossipsub.go +++ b/gossipsub.go @@ -556,12 +556,6 @@ func (gs *GossipSubRouter) connector() { } func (gs *GossipSubRouter) Publish(msg *Message) { - self := gs.p.host.ID() - if peer.ID(msg.GetFrom()) == self && msg.ReceivedFrom != self { - // we don't forward messages claiming to be from us but not published by ourselves - return - } - gs.mcache.Put(msg.Message) from := msg.ReceivedFrom @@ -573,7 +567,7 @@ func (gs *GossipSubRouter) Publish(msg *Message) { continue } - if gs.floodPublish && from == self { + if gs.floodPublish && from == gs.p.host.ID() { for p := range tmap { if gs.score.Score(p) >= gs.publishThreshold { tosend[p] = struct{}{} diff --git a/pubsub.go b/pubsub.go index 985ad8a..a4f86e9 100644 --- a/pubsub.go +++ b/pubsub.go @@ -849,6 +849,12 @@ func (p *PubSub) pushMsg(msg *Message) { } func (p *PubSub) publishMessage(msg *Message) { + self := p.host.ID() + if peer.ID(msg.GetFrom()) == self && msg.ReceivedFrom != self { + // we don't publish messages claiming to be from us but not published by ourselves + return + } + p.tracer.DeliverMessage(msg) p.notifySubs(msg) p.rt.Publish(msg)