mirror of
https://github.com/XRPLF/rippled.git
synced 2026-08-21 22:30:57 +00:00
chore: Address inline review comments on Vault helpers
- Restore the doc comment on STAmount::isRounded that was lost when it moved out of LendingHelpers.cpp. - Collapse LoanManage::defaultLoan's Vault-update block into a direct return of addVaultAssets, since there is no follow-up work after it. - Mark removeVaultAssets's amount==0 early-return with LCOV_EXCL_LINE: it is a defensive short-circuit for a branch that is only reachable in a vanishingly rare edge case (final withdrawal from a vault whose sfAssetsAvailable has already been written down to zero) and is not reached by any current transactor-level test.
This commit is contained in:
@@ -772,6 +772,10 @@ roundToAsset(
|
||||
return roundToScale(ret, scale);
|
||||
}
|
||||
|
||||
/* Checks if a value is already rounded to the specified scale.
|
||||
* Returns true if rounding down and rounding up produce the same result,
|
||||
* indicating no further precision exists beyond the scale.
|
||||
*/
|
||||
[[nodiscard]] inline bool
|
||||
isRounded(Asset const& asset, Number const& value, std::int32_t scale)
|
||||
{
|
||||
|
||||
@@ -307,7 +307,7 @@ removeVaultAssets(
|
||||
applyRemoveVaultAssets(ctx.view, vault, amount, finalRemoval);
|
||||
|
||||
if (amount == beast::kZero)
|
||||
return tesSUCCESS;
|
||||
return tesSUCCESS; // LCOV_EXCL_LINE
|
||||
|
||||
return doWithdraw(ctx, senderAcct, dstAcct, vault->at(sfAccount), priorBalance, amount, j);
|
||||
}
|
||||
|
||||
@@ -271,17 +271,13 @@ LoanManage::defaultLoan(
|
||||
|
||||
// Update the Vault's assets, and return funds from the LoanBroker
|
||||
// pseudo-account to the Vault pseudo-account:
|
||||
if (auto const ter = addVaultAssets(
|
||||
view,
|
||||
vaultSle,
|
||||
brokerSle->at(sfAccount),
|
||||
STAmount{vaultAsset, defaultCovered},
|
||||
STAmount{vaultAsset, vaultTotalDelta},
|
||||
j);
|
||||
!isTesSuccess(ter))
|
||||
return ter;
|
||||
|
||||
return tesSUCCESS;
|
||||
return addVaultAssets(
|
||||
view,
|
||||
vaultSle,
|
||||
brokerSle->at(sfAccount),
|
||||
STAmount{vaultAsset, defaultCovered},
|
||||
STAmount{vaultAsset, vaultTotalDelta},
|
||||
j);
|
||||
}
|
||||
|
||||
TER
|
||||
|
||||
Reference in New Issue
Block a user