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

Method GetTransactionFromQueue

queue.go:275–298  ·  view source on GitHub ↗

GetTransactionFromQueue retrieves a transaction from the queue by its ID. Parameters: - transactionID string: The ID of the transaction to retrieve. Returns: - *model.Transaction: A pointer to the Transaction model if found. - error: An error if the transaction could not be retrieved.

(transactionID string)

Source from the content-addressed store, hash-verified

273// - *model.Transaction: A pointer to the Transaction model if found.
274// - error: An error if the transaction could not be retrieved.
275func (q *Queue) GetTransactionFromQueue(transactionID string) (*model.Transaction, error) {
276 for i := 1; i <= q.config.Queue.NumberOfQueues; i++ {
277 queueName := fmt.Sprintf("%s_%d", q.config.Queue.TransactionQueue, i)
278 task, err := q.Inspector.GetTaskInfo(queueName, transactionID)
279 if err == nil && task != nil {
280 var txn model.Transaction
281 if err := json.Unmarshal(task.Payload, &txn); err != nil {
282 return nil, err
283 }
284 return &txn, nil
285 }
286 }
287 if q.config.Queue.EnableHotLane {
288 task, err := q.Inspector.GetTaskInfo(q.config.Queue.HotQueueName, transactionID)
289 if err == nil && task != nil {
290 var txn model.Transaction
291 if err := json.Unmarshal(task.Payload, &txn); err != nil {
292 return nil, err
293 }
294 return &txn, nil
295 }
296 }
297 return nil, nil // Return nil if transaction is not found in any queue
298}
299
300// queueInflightCommit enqueues a task to handle inflight commit for a transaction.
301//

Calls

no outgoing calls

Tested by

no test coverage detected