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

Function processResults

transaction.go:572–588  ·  view source on GitHub ↗

processResults processes the results from the results channel, collecting transactions and errors. It locks access to shared data to ensure thread safety and signals completion when done. Parameters: - results chan BatchJobResult: The channel from which to receive results. - mu *sync.Mutex: A mutex

(results chan BatchJobResult, mu *sync.Mutex, allTxns *[]*model.Transaction, allErrors *[]error, done chan struct{})

Source from the content-addressed store, hash-verified

570// - allErrors *[]error: A slice to collect all errors encountered during processing.
571// - done chan struct{}: A channel to signal when processing is complete.
572func processResults(results chan BatchJobResult, mu *sync.Mutex, allTxns *[]*model.Transaction, allErrors *[]error, done chan struct{}) {
573 for result := range results {
574 mu.Lock()
575 if result.Error != nil {
576 // Log any error encountered during transaction processing
577 logrus.Errorf("Error processing transaction: %v", result.Error)
578 *allErrors = append(*allErrors, result.Error)
579 } else if result.Txn != nil {
580 *allTxns = append(*allTxns, result.Txn)
581 } else {
582 // Handle the case where the result contains no transaction and no error
583 logrus.Warn("Received a result with no transaction and no error")
584 }
585 mu.Unlock()
586 }
587 close(done) // Signal completion of processing.
588}
589
590// fetchTransactions fetches transactions in batches and sends them to the jobs channel.
591// It starts a tracing span, iterates through the transactions, and handles context cancellation and errors.

Callers 1

Calls 3

LockMethod · 0.45
WarnMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected