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)
| 2123 | // - *model.Transaction: A pointer to the retrieved Transaction model. |
| 2124 | // - error: An error if the transaction could not be retrieved. |
| 2125 | func (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. |