CommitInflightCredit commits a credit from the inflight balance and adds it to the credit balance.
(transaction *Transaction)
| 197 | |
| 198 | // CommitInflightCredit commits a credit from the inflight balance and adds it to the credit balance. |
| 199 | func (balance *Balance) CommitInflightCredit(transaction *Transaction) { |
| 200 | balance.InitializeBalanceFields() |
| 201 | preciseAmount := ApplyPrecision(transaction) |
| 202 | transactionAmount := preciseAmount |
| 203 | |
| 204 | if balance.InflightCreditBalance.Cmp(transactionAmount) >= 0 { |
| 205 | // Deduct from inflight and add to regular credit balance. |
| 206 | balance.InflightCreditBalance.Sub(balance.InflightCreditBalance, transactionAmount) |
| 207 | balance.CreditBalance.Add(balance.CreditBalance, transactionAmount) |
| 208 | balance.computeBalance(true) // Recompute inflight balance. |
| 209 | balance.computeBalance(false) // Recompute regular balance. |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | // RollbackInflightCredit rolls back (decreases) the inflight credit balance by the specified amount. |
| 214 | func (balance *Balance) RollbackInflightCredit(amount *big.Int) { |