Skip to content

Commit

Permalink
payment finalizer: never break loop
Browse files Browse the repository at this point in the history
  • Loading branch information
kiwiidb committed Jun 15, 2023
1 parent ea0ab4e commit f99b9e9
Showing 1 changed file with 0 additions and 21 deletions.
21 changes: 0 additions & 21 deletions rabbitmq/rabbitmq.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"io"
"os"
"sync"
"time"

"github.com/getAlby/lndhub.go/db/models"
"github.com/getsentry/sentry-go"
Expand Down Expand Up @@ -167,33 +166,13 @@ func (client *DefaultClient) FinalizeInitializedPayments(ctx context.Context, sv

client.logger.Infof("Payment finalizer: Found %d pending invoices", len(pendingInvoices))

ticker := time.NewTicker(time.Hour)
defer ticker.Stop()

client.logger.Info("Starting payment finalizer rabbitmq consumer")

for {
// Shortcircuit if no pending invoices are left
if len(pendingInvoices) == 0 {
client.logger.Info("Payment finalizer: Resolved all pending payments, exiting payment finalizer routine")

return nil
}

select {
case <-ctx.Done():
return context.Canceled

case <-ticker.C:
invoices, err := getInvoicesTable(ctx)
if err != nil {
return err
}

pendingInvoices = invoices

client.logger.Infof("Payment finalizer: Found %d pending invoices", len(pendingInvoices))

case delivery, ok := <-deliveryChan:
if !ok {
return err
Expand Down

0 comments on commit f99b9e9

Please sign in to comment.