diff --git a/gossipsub.go b/gossipsub.go index 3fdbf99..227b94c 100644 --- a/gossipsub.go +++ b/gossipsub.go @@ -184,10 +184,8 @@ func (gs *GossipSubRouter) Attach(p *PubSub) { gs.p = p gs.tracer = p.tracer - // start the scoring, if any - if gs.score != nil { - gs.score.Start(gs) - } + // start the scoring + gs.score.Start(gs) // start using the same msg ID function as PubSub for caching messages. gs.mcache.SetMsgIdFn(p.msgID) diff --git a/score.go b/score.go index a16732a..4a681d3 100644 --- a/score.go +++ b/score.go @@ -294,6 +294,10 @@ func (p *TopicScoreParams) validate() error { // router interface func (ps *peerScore) Start(gs *GossipSubRouter) { + if ps == nil { + return + } + ps.msgID = gs.p.msgID ps.host = gs.p.host go ps.background(gs.p.ctx)