Skip to content

Commit

Permalink
fix: fabric check existence of listener
Browse files Browse the repository at this point in the history
Signed-off-by: Enrique Lacal <[email protected]>
  • Loading branch information
EnriqueL8 committed Jul 23, 2024
1 parent 3a2d40c commit ff764e4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
17 changes: 17 additions & 0 deletions internal/blockchain/fabric/eventstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,23 @@ func (s *streamManager) getSubscription(ctx context.Context, subID string) (sub
return sub, nil
}

func (s *streamManager) checkSubscriptionExistence(ctx context.Context, subID string) (found bool, err error) {
sub := &subscription{}
res, err := s.client.R().
SetContext(ctx).
SetResult(&sub).
Get(fmt.Sprintf("/subscriptions/%s", subID))

if err != nil || !res.IsSuccess() {
if res.StatusCode() == 404 {
return false, nil
}
return false, ffresty.WrapRestErr(ctx, res, err, coremsgs.MsgFabconnectRESTErr)
}

return true, nil
}

func (s *streamManager) getSubscriptionName(ctx context.Context, subID string) (string, error) {
if cachedValue := s.cache.GetString("sub:" + subID); cachedValue != "" {
return cachedValue, nil
Expand Down
8 changes: 7 additions & 1 deletion internal/blockchain/fabric/fabric.go
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,13 @@ func (f *Fabric) DeleteContractListener(ctx context.Context, subscription *core.

func (f *Fabric) GetContractListenerStatus(ctx context.Context, namespace, subID string, okNotFound bool) (bool, interface{}, core.ContractListenerStatus, error) {
// Fabconnect does not currently provide any additional status info for listener subscriptions.
return true, nil, core.ContractListenerStatusUnknown, nil
// But we check for existence of the subscription
found, err := f.streams.checkSubscriptionExistence(ctx, subID)
if err != nil {
return found, nil, core.ContractListenerStatusUnknown, err
}

return found, nil, core.ContractListenerStatusUnknown, nil
}

func (f *Fabric) GetFFIParamValidator(ctx context.Context) (fftypes.FFIParamValidator, error) {
Expand Down

0 comments on commit ff764e4

Please sign in to comment.