MCPcopy Index your code
hub / github.com/devaccuracy/ledgerforge / processSingleTransaction

Method processSingleTransaction

transaction.go:1950–1966  ·  view source on GitHub ↗

processSingleTransaction handles the processing of a single (non-split) transaction. It prepares the transaction, persists it to the database, and creates a queue copy. Parameters: - ctx context.Context: The context for the operation. - transaction *model.Transaction: The single transaction to proc

(ctx context.Context, transaction *model.Transaction, originalRef string)

Source from the content-addressed store, hash-verified

1948// - []*model.Transaction: A slice containing the processed transaction ready for queueing.
1949// - error: An error if the transaction processing fails.
1950func (l *LedgerForge) processSingleTransaction(ctx context.Context, transaction *model.Transaction, originalRef string) ([]*model.Transaction, error) {
1951 if len(transaction.Sources) == 0 && len(transaction.Destinations) == 0 {
1952 preparedTxn, err := l.prepareTransactionForQueue(ctx, transaction)
1953 if err != nil {
1954 return nil, err
1955 }
1956 transaction = preparedTxn
1957 }
1958
1959 persistedTxn, err := l.datasource.RecordTransaction(ctx, transaction)
1960 if err != nil {
1961 return nil, fmt.Errorf("failed to persist original transaction: %w", err)
1962 }
1963
1964 queueTxn := createQueueCopy(persistedTxn, originalRef)
1965 return []*model.Transaction{queueTxn}, nil
1966}
1967
1968// processSplitTransactions handles the processing of multiple split transactions.
1969// It prepares each split transaction, persists them to the database, and creates queue copies.

Callers 1

processTxnsMethod · 0.95

Calls 3

createQueueCopyFunction · 0.85
RecordTransactionMethod · 0.65

Tested by

no test coverage detected