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

Method HasPendingCreditOutbox

database/lineage.go:433–445  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
433func (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}

Callers

nothing calls this directly

Calls 1

NewAPIErrorFunction · 0.92

Tested by

no test coverage detected