more refactoring

This commit is contained in:
kiwiidb
2023-09-22 10:43:42 +02:00
parent b5240fd7fd
commit 08e5b6fc54
13 changed files with 65 additions and 63 deletions

View File

@@ -0,0 +1,32 @@
package service
import (
"context"
)
func (svc *LndhubService) StartInvoiceRoutine(ctx context.Context) (err error) {
if svc.RabbitMQClient != nil {
err = svc.RabbitMQClient.SubscribeToLndInvoices(ctx, svc.ProcessInvoiceUpdate)
if err != nil && err != context.Canceled {
return err
}
return nil
} else {
err = svc.InvoiceUpdateSubscription(ctx)
if err != nil && err != context.Canceled {
// in case of an error in this routine, we want to restart LNDhub
return err
}
return nil
}
}
func (svc *LndhubService) StartPendingPaymentRoutine(ctx context.Context) (err error) {
if svc.RabbitMQClient != nil {
return svc.RabbitMQClient.FinalizeInitializedPayments(ctx, svc)
} else {
return svc.CheckAllPendingOutgoingPayments(ctx)
}
}