mirror of
https://github.com/logos-messaging/logos-messaging-go.git
synced 2026-01-08 17:03:09 +00:00
fix: unsubscribe from all peers unless specified and check err code when full node has no subscription
This commit is contained in:
parent
0822fdb280
commit
7dd02067f8
@ -256,10 +256,6 @@ func (wf *WakuFilterLightnode) getUnsubscribeParameters(opts ...FilterUnsubscrib
|
|||||||
opt(params)
|
opt(params)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !params.unsubscribeAll && params.selectedPeer == "" {
|
|
||||||
return nil, ErrNoPeersAvailable
|
|
||||||
}
|
|
||||||
|
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,7 +346,7 @@ func (wf *WakuFilterLightnode) Unsubscribe(ctx context.Context, contentFilter Co
|
|||||||
resultChan := make(chan WakuFilterPushResult, len(wf.subscriptions.items))
|
resultChan := make(chan WakuFilterPushResult, len(wf.subscriptions.items))
|
||||||
|
|
||||||
for peerID := range wf.subscriptions.items {
|
for peerID := range wf.subscriptions.items {
|
||||||
if !params.unsubscribeAll && peerID != params.selectedPeer {
|
if params.selectedPeer != "" && peerID != params.selectedPeer {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,8 +359,13 @@ func (wf *WakuFilterLightnode) Unsubscribe(ctx context.Context, contentFilter Co
|
|||||||
pb.FilterSubscribeRequest_UNSUBSCRIBE,
|
pb.FilterSubscribeRequest_UNSUBSCRIBE,
|
||||||
contentFilter)
|
contentFilter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wf.log.Error("could not unsubscribe from peer", logging.HostID("peerID", peerID), zap.Error(err))
|
ferr, ok := err.(*FilterError)
|
||||||
return
|
if ok && ferr.Code == http.StatusNotFound {
|
||||||
|
wf.log.Warn("peer does not have a subscription", logging.HostID("peerID", peerID), zap.Error(err))
|
||||||
|
} else {
|
||||||
|
wf.log.Error("could not unsubscribe from peer", logging.HostID("peerID", peerID), zap.Error(err))
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wf.cleanupSubscriptions(peerID, contentFilter)
|
wf.cleanupSubscriptions(peerID, contentFilter)
|
||||||
@ -408,7 +409,7 @@ func (wf *WakuFilterLightnode) UnsubscribeAll(ctx context.Context, opts ...Filte
|
|||||||
resultChan := make(chan WakuFilterPushResult, len(wf.subscriptions.items))
|
resultChan := make(chan WakuFilterPushResult, len(wf.subscriptions.items))
|
||||||
|
|
||||||
for peerID := range wf.subscriptions.items {
|
for peerID := range wf.subscriptions.items {
|
||||||
if !params.unsubscribeAll && peerID != params.selectedPeer {
|
if params.selectedPeer != "" && peerID != params.selectedPeer {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
localWg.Add(1)
|
localWg.Add(1)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user