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

Method GetTransaction

transaction.go:2125–2138  ·  view source on GitHub ↗

GetTransaction retrieves a transaction by its ID from the datasource. It starts a tracing span, fetches the transaction, and records relevant events and errors. Parameters: - ctx context.Context: The context for the operation. - TransactionID string: The ID of the transaction to be retrieved. Retu

(ctx context.Context, TransactionID string)

Source from the content-addressed store, hash-verified

2123// - *model.Transaction: A pointer to the retrieved Transaction model.
2124// - error: An error if the transaction could not be retrieved.
2125func (l *LedgerForge) GetTransaction(ctx context.Context, TransactionID string) (*model.Transaction, error) {
2126 ctx, span := tracer.Start(ctx, "GetTransaction")
2127 defer span.End()
2128
2129 // Fetch the transaction from the datasource
2130 transaction, err := l.datasource.GetTransaction(ctx, TransactionID)
2131 if err != nil {
2132 span.RecordError(err)
2133 return nil, err
2134 }
2135
2136 span.AddEvent("Transaction retrieved", trace.WithAttributes(attribute.String("transaction.id", TransactionID)))
2137 return transaction, nil
2138}
2139
2140// GetAllTransactions retrieves all transactions from the datasource.
2141// It starts a tracing span, fetches all transactions, and records relevant events and errors.

Callers 4

TestGetTransaction_MockFunction · 0.95
UpdateMetadataMethod · 0.95
GetTransactionLineageMethod · 0.95

Calls 2

GetTransactionMethod · 0.65
StartMethod · 0.45

Tested by 1

TestGetTransaction_MockFunction · 0.76