processBulkTransactions prepares and queues all transactions in a batch with the given batch ID
(ctx context.Context, transactions []*model.Transaction, batchID string, inflight bool, skipQueue bool)
| 2377 | |
| 2378 | // processBulkTransactions prepares and queues all transactions in a batch with the given batch ID |
| 2379 | func (l *LedgerForge) processBulkTransactions(ctx context.Context, transactions []*model.Transaction, batchID string, inflight bool, skipQueue bool) error { |
| 2380 | for i, txn := range transactions { |
| 2381 | // Set transaction properties |
| 2382 | txn.Inflight = inflight |
| 2383 | txn.SkipQueue = skipQueue // Process synchronously within the batch context first |
| 2384 | txn.ParentTransaction = batchID |
| 2385 | |
| 2386 | // Add sequence number to metadata |
| 2387 | if txn.MetaData == nil { |
| 2388 | txn.MetaData = make(map[string]interface{}) |
| 2389 | } |
| 2390 | txn.MetaData["sequence"] = i + 1 |
| 2391 | |
| 2392 | // Queue the transaction (which will record it if SkipQueue is true) |
| 2393 | if _, err := l.QueueTransaction(ctx, txn); err != nil { |
| 2394 | // Create a more descriptive error that includes transaction reference details |
| 2395 | return fmt.Errorf("failed to queue transaction %d (Reference: %s, Source: %s, Destination: %s, Amount: %.2f): %w", |
| 2396 | i+1, txn.Reference, txn.Source, txn.Destination, txn.Amount, err) |
| 2397 | } |
| 2398 | } |
| 2399 | return nil |
| 2400 | } |
| 2401 | |
| 2402 | // rollbackBatchTransactions performs a rollback of transactions in a batch |
| 2403 | // Returns the action performed (voided/refunded) and any error that occurred |
no test coverage detected