From 26bbb69d8d3d5f6a703ecb1da59239285ab80add Mon Sep 17 00:00:00 2001 From: Prem Chaitanya Prathi Date: Sat, 9 Nov 2024 17:29:29 +0700 Subject: [PATCH] fix: add stop method for missing message verifier --- waku/v2/api/missing/missing_messages.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/waku/v2/api/missing/missing_messages.go b/waku/v2/api/missing/missing_messages.go index 72ac4f9f3..b10a9de9a 100644 --- a/waku/v2/api/missing/missing_messages.go +++ b/waku/v2/api/missing/missing_messages.go @@ -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 @@ -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) @@ -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 {