mirror of
https://github.com/getAlby/hub.git
synced 2026-08-13 12:33:39 +02:00
fix: check lnclient in event handler (#1987)
* fix: check lnclient in event handler * fix: stop processing subscriptions events channel if context is done
This commit is contained in:
parent
8c9aeff5b3
commit
a5f2c2d692
2 changed files with 13 additions and 1 deletions
|
|
@ -47,6 +47,13 @@ func (svc *nip47Service) HandleEvent(ctx context.Context, pool nostrmodels.Simpl
|
|||
return
|
||||
}
|
||||
|
||||
if lnClient == nil {
|
||||
logger.Logger.WithFields(logrus.Fields{
|
||||
"requestEventNostrId": event.ID,
|
||||
}).Error("cannot handle event due to LNClient not started")
|
||||
return
|
||||
}
|
||||
|
||||
// store request event
|
||||
requestEvent := db.RequestEvent{AppId: nil, NostrId: event.ID, State: db.REQUEST_EVENT_STATE_HANDLER_EXECUTING}
|
||||
err = svc.db.Create(&requestEvent).Error
|
||||
|
|
|
|||
|
|
@ -231,7 +231,12 @@ func (svc *service) watchSubscription(ctx context.Context, pool *nostr.SimplePoo
|
|||
go func() {
|
||||
// loop through incoming events
|
||||
for event := range eventsChannel {
|
||||
go svc.nip47Service.HandleEvent(ctx, pool, event.Event, svc.lnClient)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
default:
|
||||
go svc.nip47Service.HandleEvent(ctx, pool, event.Event, svc.lnClient)
|
||||
}
|
||||
}
|
||||
logger.Logger.Debug("Relay subscription events channel ended")
|
||||
eventsChannelClosed <- struct{}{}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue