RefundWorker processes refund transactions from the jobs channel and sends the results to the results channel. It starts a tracing span, processes each transaction, and records relevant events and errors. Parameters: - ctx context.Context: The context for the operation. - jobs <-chan *model.Transac
(ctx context.Context, jobs <-chan *model.Transaction, results chan<- BatchJobResult, wg *sync.WaitGroup, amount *big.Int)
| 734 | // - wg *sync.WaitGroup: A wait group to synchronize the completion of the worker. |
| 735 | // - amount float64: The amount to be processed in the transaction. |
| 736 | func (l *LedgerForge) RefundWorker(ctx context.Context, jobs <-chan *model.Transaction, results chan<- BatchJobResult, wg *sync.WaitGroup, amount *big.Int) { |
| 737 | ctx, span := tracer.Start(ctx, "RefundWorker") |
| 738 | defer span.End() |
| 739 | |
| 740 | defer wg.Done() |
| 741 | for originalTxn := range jobs { |
| 742 | queuedRefundTxn, err := l.RefundTransaction(ctx, originalTxn.TransactionID, originalTxn.SkipQueue) |
| 743 | if err != nil { |
| 744 | results <- BatchJobResult{Error: err} |
| 745 | span.RecordError(err) |
| 746 | continue |
| 747 | } |
| 748 | results <- BatchJobResult{Txn: queuedRefundTxn} |
| 749 | span.AddEvent("Refund processed", trace.WithAttributes(attribute.String("transaction.id", queuedRefundTxn.TransactionID))) |
| 750 | } |
| 751 | } |
| 752 | |
| 753 | // ProcessQueuedTransaction preserves the existing queued-worker behavior while routing the |
| 754 | // decision through the shared internal transaction executor. |