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

Method processAllocations

lineage.go:561–582  ·  view source on GitHub ↗

processAllocations processes fund allocations by queuing release and receive transactions. Parameters: - ctx context.Context: The context for the operation. - txn *model.Transaction: The original transaction. - allocations []Allocation: The calculated allocations. - mappings []model.LineageMapping:

(ctx context.Context, txn *model.Transaction, allocations []Allocation, mappings []model.LineageMapping, sourceBalance, destinationBalance, sourceAggBalance *model.Balance, destLineageBalances map[string]*destinationLineageInfo)

Source from the content-addressed store, hash-verified

559// - sourceAggBalance *model.Balance: The source aggregate balance.
560// - destLineageBalances map[string]*destinationLineageInfo: Pre-created destination lineage balances (may be nil).
561func (l *LedgerForge) processAllocations(ctx context.Context, txn *model.Transaction, allocations []Allocation, mappings []model.LineageMapping, sourceBalance, destinationBalance, sourceAggBalance *model.Balance, destLineageBalances map[string]*destinationLineageInfo) {
562 for i, alloc := range allocations {
563 if alloc.Amount.Cmp(big.NewInt(0)) == 0 {
564 continue
565 }
566
567 mapping := l.findMappingByShadowID(mappings, alloc.BalanceID)
568 if mapping == nil {
569 continue
570 }
571
572 if err := l.queueReleaseTransaction(ctx, txn, alloc, mapping, sourceBalance, sourceAggBalance, i); err != nil {
573 logrus.Errorf("failed to queue release transaction: %v", err)
574 continue
575 }
576
577 if err := l.processDestinationLineage(ctx, txn, alloc, mapping, sourceBalance, destinationBalance, destLineageBalances, i); err != nil {
578 logrus.Errorf("failed to process destination lineage: %v", err)
579 // Continue processing other allocations even if one fails
580 }
581 }
582}
583
584// queueReleaseTransaction queues a transaction to release funds from the aggregate balance back to a shadow balance.
585//

Callers 1

processLineageDebitMethod · 0.95

Calls 3

findMappingByShadowIDMethod · 0.95

Tested by

no test coverage detected