cashless2ecash

cashless2ecash: pay with cards for digital cash (experimental)
Log | Files | Refs | README

commit 527b1bd20a7cb52a74c6ebe878914d17f1d344ff
parent bdfa9186ab8e3b92cb92e9887a6779035a171d3b
Author: Joel-Haeberli <haebu@rubigen.ch>
Date:   Sat, 18 May 2024 13:35:20 +0200

fix: retrier

Diffstat:
Mc2ec/proc-retrier.go | 27++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/c2ec/proc-retrier.go b/c2ec/proc-retrier.go @@ -2,6 +2,7 @@ package main import ( "context" + "errors" "strconv" "time" ) @@ -22,7 +23,15 @@ func RunRetrier(ctx context.Context, errs chan error) { go func() { for { time.Sleep(time.Duration(CONFIG.Server.RetryDelayMs) * time.Millisecond) - + withdrawals, err := DB.GetAttestableWithdrawals() + if err != nil { + LogError("proc-retrier", err) + errs <- err + continue + } + for _, w := range withdrawals { + attest(w, errs) + } } }() } @@ -43,6 +52,18 @@ func retryCallback(n *Notification, errs chan error) { return } + attest(withdrawal, errs) +} + +func attest(withdrawal *Withdrawal, errs chan error) { + + if withdrawal == nil { + err := errors.New("withdrawal was null") + LogError("proc-retrier", err) + errs <- err + return + } + provider, err := DB.GetProviderByTerminal(withdrawal.TerminalId) if err != nil { LogError("proc-retrier", err) @@ -50,7 +71,7 @@ func retryCallback(n *Notification, errs chan error) { return } - err = DB.SetRetryCounter(withdrawalId, int(withdrawal.RetryCounter)+1) + err = DB.SetRetryCounter(int(withdrawal.WithdrawalRowId), int(withdrawal.RetryCounter)+1) if err != nil { LogError("proc-retrier", err) errs <- err @@ -65,5 +86,5 @@ func retryCallback(n *Notification, errs chan error) { return } - finaliseOrSetRetry(transaction, withdrawalId, errs) + finaliseOrSetRetry(transaction, int(withdrawal.WithdrawalRowId), errs) }