move score starting nil check inside the score implementation

This commit is contained in:
vyzo 2020-03-16 21:27:52 +02:00
parent ff89a0e619
commit d5e432a62b
2 changed files with 6 additions and 4 deletions

View File

@ -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)

View File

@ -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)