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

Method GetBalanceByIndicator

balance.go:616–633  ·  view source on GitHub ↗

GetBalanceByIndicator retrieves a balance by its indicator and currency. It starts a tracing span, fetches the balance, and records relevant events. Parameters: - ctx context.Context: The context for the operation. - indicator string: The indicator of the balance to retrieve. - currency string: The

(ctx context.Context, indicator, currency string)

Source from the content-addressed store, hash-verified

614// - *model.Balance: A pointer to the Balance model if found.
615// - error: An error if the balance could not be retrieved.
616func (l *LedgerForge) GetBalanceByIndicator(ctx context.Context, indicator, currency string) (*model.Balance, error) {
617 _, span := balanceTracer.Start(ctx, "GetBalanceByIndicator")
618 defer span.End()
619
620 span.SetAttributes(
621 attribute.String("balance.indicator", indicator),
622 attribute.String("balance.currency", currency),
623 )
624
625 balance, err := l.datasource.GetBalanceByIndicator(indicator, currency)
626 if err != nil {
627 span.RecordError(err)
628 return nil, err
629 }
630
631 span.AddEvent("Balance retrieved by indicator", trace.WithAttributes(attribute.String("balance.id", balance.BalanceID)))
632 return balance, nil
633}
634
635// UpdateBalanceIdentity updates only the identity_id associated with a balance.
636// It validates that both the balance and the identity exist before applying the change.

Callers 1

Calls 2

GetBalanceByIndicatorMethod · 0.65
StartMethod · 0.45

Tested by 1