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)