Skip to content

Commit

Permalink
fix: add stop method for missing message verifier
Browse files Browse the repository at this point in the history
  • Loading branch information
chaitanyaprem committed Nov 9, 2024
1 parent 213d382 commit aadfbd6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions waku/v2/api/missing/missing_messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type MessageTracker interface {
// MissingMessageVerifier is used to periodically retrieve missing messages from store nodes that have some specific criteria
type MissingMessageVerifier struct {
ctx context.Context
cancel context.CancelFunc
params missingMessageVerifierParams

messageTracker MessageTracker
Expand Down Expand Up @@ -96,7 +97,9 @@ func (m *MissingMessageVerifier) SetCriteriaInterest(peerID peer.ID, contentFilt
}

func (m *MissingMessageVerifier) Start(ctx context.Context) {
ctx, cancelFunc := context.WithCancel(ctx)
m.ctx = ctx
m.cancel = cancelFunc
m.criteriaInterest = make(map[string]criteriaInterest)

c := make(chan *protocol.Envelope, 1000)
Expand Down Expand Up @@ -139,6 +142,10 @@ func (m *MissingMessageVerifier) Start(ctx context.Context) {
}()
}

func (m *MissingMessageVerifier) Stop() {
m.cancel()
}

func (m *MissingMessageVerifier) fetchHistory(c chan<- *protocol.Envelope, interest criteriaInterest) {
contentTopics := interest.contentFilter.ContentTopics.ToList()
for i := 0; i < len(contentTopics); i += maxContentTopicsPerRequest {
Expand Down

0 comments on commit aadfbd6

Please sign in to comment.