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

Method persistSingleTransactionExecutionWork

transaction.go:1279–1296  ·  view source on GitHub ↗

persistSingleTransactionExecutionWork atomically persists one prepared transaction, its updated balances, and any lineage outbox using the shared execution work shape.

(ctx context.Context, work queuedBatchPostCommitWork)

Source from the content-addressed store, hash-verified

1277// persistSingleTransactionExecutionWork atomically persists one prepared transaction, its
1278// updated balances, and any lineage outbox using the shared execution work shape.
1279func (l *LedgerForge) persistSingleTransactionExecutionWork(ctx context.Context, work queuedBatchPostCommitWork) (queuedBatchPostCommitWork, error) {
1280 ctx, span := tracer.Start(ctx, "PersistSingleTransactionExecutionWork")
1281 defer span.End()
1282
1283 transaction, err := l.datasource.RecordTransactionWithBalancesAndOutbox(ctx, work.transaction, work.sourceBalance, work.destinationBalance, work.outbox)
1284 if err != nil {
1285 span.RecordError(err)
1286 return queuedBatchPostCommitWork{}, l.logAndRecordError(span, "failed to persist transaction with balances", err)
1287 }
1288
1289 work.transaction = transaction
1290 span.AddEvent("Transaction and balances persisted atomically", trace.WithAttributes(
1291 attribute.String("transaction.id", transaction.TransactionID),
1292 attribute.Bool("lineage.outbox_created", work.outbox != nil),
1293 ))
1294
1295 return work, nil
1296}
1297
1298func (l *LedgerForge) prepareTransactionOutbox(ctx context.Context, transaction *model.Transaction, sourceBalance, destinationBalance *model.Balance) *model.LineageOutbox {
1299 if transaction.Status != StatusApplied && transaction.Status != StatusInflight {

Callers 1

Calls 3

logAndRecordErrorMethod · 0.95
StartMethod · 0.45

Tested by

no test coverage detected