HasPendingCreditOutbox checks if there are pending credit outbox entries for a given balance. This is used to detect race conditions where a debit is being processed before credits are complete.
(ctx context.Context, balanceID string)
| 431 | // HasPendingCreditOutbox checks if there are pending credit outbox entries for a given balance. |
| 432 | // This is used to detect race conditions where a debit is being processed before credits are complete. |
| 433 | func (d Datasource) HasPendingCreditOutbox(ctx context.Context, balanceID string) (bool, error) { |
| 434 | var count int |
| 435 | err := d.Conn.QueryRowContext(ctx, ` |
| 436 | SELECT COUNT(*) FROM ledgerforge.lineage_outbox |
| 437 | WHERE destination_balance_id = $1 |
| 438 | AND lineage_type IN ('credit', 'both') |
| 439 | AND status IN ('pending', 'processing') |
| 440 | `, balanceID).Scan(&count) |
| 441 | if err != nil { |
| 442 | return false, apierror.NewAPIError(apierror.ErrInternalServer, "Failed to check pending credit outbox", err) |
| 443 | } |
| 444 | return count > 0, nil |
| 445 | } |
nothing calls this directly
no test coverage detected