diff --git a/gossipsub.go b/gossipsub.go index 85dab43..b4d9933 100644 --- a/gossipsub.go +++ b/gossipsub.go @@ -97,7 +97,7 @@ func WithPeerScore(params *PeerScoreParams, gossipThreshold, publishThreshold, g return fmt.Errorf("pubsub router is not gossipsub") } - gs.score = newPeerScore(gs, params) + gs.score = newPeerScore(params) gs.gossipThreshold = gossipThreshold gs.publishThreshold = publishThreshold gs.graylistThreshold = graylistThreshold @@ -178,9 +178,19 @@ func (gs *GossipSubRouter) Protocols() []protocol.ID { 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 using the same msg ID function as PubSub for caching messages. gs.mcache.SetMsgIdFn(p.msgID) + + // start the heartbeat go gs.heartbeatTimer() + + // start the PX connectors for i := 0; i < GossipSubConnectors; i++ { go gs.connector() } diff --git a/score.go b/score.go index c0a9667..9ecfa54 100644 --- a/score.go +++ b/score.go @@ -79,11 +79,15 @@ type TopicScoreParams struct { type peerScore struct { } -func newPeerScore(gs *GossipSubRouter, params *PeerScoreParams) *peerScore { +func newPeerScore(params *PeerScoreParams) *peerScore { return nil } // router interface +func (ps *peerScore) Start(gs *GossipSubRouter) { + +} + func (ps *peerScore) Score(p peer.ID) float64 { return 0 }