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)
| 752 | // - allocations []Allocation: The calculated allocations. |
| 753 | // - mappings []model.LineageMapping: The lineage mappings. |
| 754 | func (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 | // |
no test coverage detected