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

Method getSourceAggregateBalance

lineage.go:533–548  ·  view source on GitHub ↗

getSourceAggregateBalance retrieves or creates the aggregate balance for the source identity. Parameters: - ctx context.Context: The context for the operation. - sourceBalance *model.Balance: The source balance. Returns: - *model.Balance: The aggregate balance. - error: An error if the balance cou

(ctx context.Context, sourceBalance *model.Balance)

Source from the content-addressed store, hash-verified

531// - *model.Balance: The aggregate balance.
532// - error: An error if the balance could not be retrieved or created.
533func (l *LedgerForge) getSourceAggregateBalance(ctx context.Context, sourceBalance *model.Balance) (*model.Balance, error) {
534 sourceIdentity, err := l.datasource.GetIdentityByID(sourceBalance.IdentityID)
535 if err != nil {
536 return nil, fmt.Errorf("failed to get source identity: %w", err)
537 }
538
539 sourceIdentifier := l.getIdentityIdentifier(sourceIdentity)
540 sourceAggIndicator := fmt.Sprintf("@%s_lineage", sourceIdentifier)
541
542 sourceAggBalance, err := l.getOrCreateBalanceByIndicator(ctx, sourceAggIndicator, sourceBalance.Currency)
543 if err != nil {
544 return nil, fmt.Errorf("failed to get source aggregate balance: %w", err)
545 }
546
547 return sourceAggBalance, nil
548}
549
550// processAllocations processes fund allocations by queuing release and receive transactions.
551//

Callers 1

processLineageDebitMethod · 0.95

Calls 3

getIdentityIdentifierMethod · 0.95
GetIdentityByIDMethod · 0.65

Tested by

no test coverage detected