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 Dec 2, 2024
1 parent 192fa9e commit 313c6bf
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 @@ -35,6 +35,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

storenodeRequestor common.StorenodeRequestor
Expand Down Expand Up @@ -98,7 +99,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 @@ -141,6 +144,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 313c6bf

Please sign in to comment.