chore: stop light filter node by default (#964)

This commit is contained in:
kaichao 2023-12-21 08:44:51 +08:00 committed by GitHub
parent 5e3c9fdfa1
commit b4ba7b75d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 11 deletions

View File

@ -529,6 +529,7 @@ func (w *WakuNode) Stop() {
w.store.Stop() w.store.Stop()
w.legacyFilter.Stop() w.legacyFilter.Stop()
w.filterFullNode.Stop() w.filterFullNode.Stop()
w.filterLightNode.Stop()
if w.opts.enableDiscV5 { if w.opts.enableDiscV5 {
w.discoveryV5.Stop() w.discoveryV5.Stop()

View File

@ -112,19 +112,23 @@ func (wf *WakuFilterLightNode) Stop() {
wf.CommonService.Stop(func() { wf.CommonService.Stop(func() {
wf.h.RemoveStreamHandler(FilterPushID_v20beta1) wf.h.RemoveStreamHandler(FilterPushID_v20beta1)
if wf.subscriptions.Count() > 0 { if wf.subscriptions.Count() > 0 {
res, err := wf.unsubscribeAll(wf.Context()) go func() {
if err != nil { defer func() {
wf.log.Warn("unsubscribing from full nodes", zap.Error(err)) _ = recover()
} }()
res, err := wf.unsubscribeAll(wf.Context())
for _, r := range res.Errors() { if err != nil {
if r.Err != nil { wf.log.Warn("unsubscribing from full nodes", zap.Error(err))
wf.log.Warn("unsubscribing from full nodes", zap.Error(r.Err), logging.HostID("peerID", r.PeerID))
} }
} for _, r := range res.Errors() {
// if r.Err != nil {
wf.subscriptions.Clear() wf.log.Warn("unsubscribing from full nodes", zap.Error(r.Err), logging.HostID("peerID", r.PeerID))
}
}
wf.subscriptions.Clear()
}()
} }
}) })
} }
@ -617,6 +621,7 @@ func (wf *WakuFilterLightNode) unsubscribeAll(ctx context.Context, opts ...Filte
if params.wg != nil { if params.wg != nil {
params.wg.Done() params.wg.Done()
} }
_ = recover()
}() }()
paramsCopy := params.Copy() paramsCopy := params.Copy()