MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / processTransactions

Method processTransactions

reconciliation.go:536–576  ·  view source on GitHub ↗

processTransactions processes the transactions in batches, applying the reconciliation logic for each transaction. Parameters: - ctx: The context controlling the request. - uploadID: The ID of the uploaded transaction file to reconcile. - processor: The transaction processor handling the reconciliat

(ctx context.Context, uploadID string, processor *transactionProcessor, strategy string)

Source from the content-addressed store, hash-verified

534// Returns:
535// - error: If any error occurs during processing.
536func (s *LedgerForge) processTransactions(ctx context.Context, uploadID string, processor *transactionProcessor, strategy string) error {
537 conf, err := config.Fetch()
538 if err != nil {
539 return err
540 }
541 processedCount := 0
542 var transactionProcessor getTxns
543 // Use different transaction retrieval methods depending on the strategy.
544 if strategy == "many_to_one" {
545 transactionProcessor = s.getInternalTransactionsPaginated
546 } else {
547 transactionProcessor = s.getExternalTransactionsPaginated
548 }
549
550 // Process the transactions in batches.
551 _, err = s.ProcessTransactionInBatches(
552 ctx,
553 uploadID,
554 big.NewInt(0),
555 conf.Transaction.MaxWorkers,
556 false, // Stream mode is disabled.
557 transactionProcessor,
558 func(ctx context.Context, txns <-chan *model.Transaction, results chan<- BatchJobResult, wg *sync.WaitGroup, _ *big.Int) {
559 defer wg.Done()
560 for txn := range txns {
561 if err := processor.process(ctx, txn); err != nil {
562 logrus.Errorf("Error processing transaction %s: %v", txn.TransactionID, err)
563 results <- BatchJobResult{Error: err}
564 return
565 }
566 processedCount++
567 if processedCount%10 == 0 {
568 logrus.Infof("Processed %d transactions", processedCount)
569 }
570 results <- BatchJobResult{}
571 }
572 },
573 )
574 logrus.Infof("Total transactions processed: %d", processedCount)
575 return err
576}
577
578// finalizeReconciliation finalizes the reconciliation process by updating its status and recording the final match/unmatch counts.
579// Parameters:

Callers 1

processReconciliationMethod · 0.95

Calls 3

FetchFunction · 0.92
processMethod · 0.80

Tested by

no test coverage detected