Skip to content

Commit 6300c5d

Browse files
authored
fix: re-enqueue failed info publish request (#1300)
1 parent 8e8a11f commit 6300c5d

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

nip47/nip47_service.go

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package nip47
22

33
import (
44
"context"
5+
"time"
56

67
"github.com/getAlby/hub/alby"
78
"github.com/getAlby/hub/apps"
@@ -99,6 +100,9 @@ func (svc *nip47Service) StartNip47InfoPublisher(relay *nostr.Relay, lnClient ln
99100
_, err := svc.PublishNip47Info(relay.Context(), relay, req.AppWalletPubKey, req.AppWalletPrivKey, lnClient)
100101
if err != nil {
101102
logger.Logger.WithError(err).WithField("wallet_pubkey", req.AppWalletPubKey).Error("Failed to publish NIP47 info from queue")
103+
// wait and then re-add the item to the queue
104+
time.Sleep(5 * time.Second)
105+
svc.EnqueueNip47InfoPublishRequest(req.AppWalletPubKey, req.AppWalletPrivKey)
102106
}
103107
}
104108
}

service/create_app_consumer.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,9 @@ func (s *createAppConsumer) ConsumeEvent(ctx context.Context, event *events.Even
5656
logger.Logger.WithError(err).Error("Failed to calculate app wallet pub key")
5757
return
5858
}
59+
s.svc.nip47Service.EnqueueNip47InfoPublishRequest(walletPubKey, walletPrivKey)
5960

6061
go func() {
61-
_, err := s.svc.GetNip47Service().PublishNip47Info(ctx, s.relay, walletPubKey, walletPrivKey, s.svc.lnClient)
62-
if err != nil {
63-
logger.Logger.WithError(err).Error("Could not publish NIP47 info")
64-
}
6562
err = s.svc.startAppWalletSubscription(ctx, s.relay, walletPubKey)
6663
if err != nil && !errors.Is(err, context.Canceled) {
6764
logger.Logger.WithError(err).WithFields(logrus.Fields{

service/update_app_consumer.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ func (s *updateAppConsumer) ConsumeEvent(ctx context.Context, event *events.Even
4343

4444
if s.svc.keys.GetNostrPublicKey() != walletPubKey {
4545
// only need to re-publish the nip47 event info if it is not a legacy wallet
46-
47-
_, err = s.svc.GetNip47Service().PublishNip47Info(ctx, s.relay, walletPubKey, walletPrivKey, s.svc.lnClient)
48-
if err != nil {
49-
logger.Logger.WithError(err).Error("Could not re-publish NIP47 info")
50-
}
51-
46+
s.svc.nip47Service.EnqueueNip47InfoPublishRequest(walletPubKey, walletPrivKey)
5247
}
5348
}

0 commit comments

Comments
 (0)