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

Method updateFundAllocationMetadata

lineage.go:754–770  ·  view source on GitHub ↗

updateFundAllocationMetadata updates the transaction metadata with fund allocation details. Parameters: - ctx context.Context: The context for the operation. - txn *model.Transaction: The transaction to update. - allocations []Allocation: The calculated allocations. - mappings []model.LineageMappin

(ctx context.Context, txn *model.Transaction, allocations []Allocation, mappings []model.LineageMapping)

Source from the content-addressed store, hash-verified

752// - allocations []Allocation: The calculated allocations.
753// - mappings []model.LineageMapping: The lineage mappings.
754func (l *LedgerForge) updateFundAllocationMetadata(ctx context.Context, txn *model.Transaction, allocations []Allocation, mappings []model.LineageMapping) {
755 if len(allocations) == 0 {
756 return
757 }
758
759 fundAllocation := l.buildFundAllocationList(allocations, mappings, txn.Precision)
760 if len(fundAllocation) == 0 {
761 return
762 }
763
764 newMetadata := map[string]interface{}{
765 LineageFundAllocation: fundAllocation,
766 }
767 if err := l.datasource.UpdateTransactionMetadata(ctx, txn.TransactionID, newMetadata); err != nil {
768 logrus.Errorf("failed to update transaction with fund allocation: %v", err)
769 }
770}
771
772// buildFundAllocationList builds a list of fund allocations for metadata storage.
773//

Callers 1

processLineageDebitMethod · 0.95

Calls 2

Tested by

no test coverage detected