mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
review feedback: Use the specific type in the "SendMulti" functions
This commit is contained in:
@@ -2113,26 +2113,26 @@ static TER
|
||||
rippleSendMultiIOU(
|
||||
ApplyView& view,
|
||||
AccountID const& senderID,
|
||||
Asset const& asset,
|
||||
Issue const& issue,
|
||||
MultiplePaymentDestinations const& receivers,
|
||||
STAmount& actual,
|
||||
beast::Journal j,
|
||||
WaiveTransferFee waiveFee)
|
||||
{
|
||||
auto const issuer = asset.getIssuer();
|
||||
auto const issuer = issue.getIssuer();
|
||||
|
||||
XRPL_ASSERT(
|
||||
!isXRP(senderID), "ripple::rippleSendMultiIOU : sender is not XRP");
|
||||
|
||||
// These may diverge
|
||||
STAmount takeFromSender{asset};
|
||||
STAmount takeFromSender{issue};
|
||||
actual = takeFromSender;
|
||||
|
||||
// Failures return immediately.
|
||||
for (auto const& r : receivers)
|
||||
{
|
||||
auto const& receiverID = r.first;
|
||||
STAmount amount{asset, r.second};
|
||||
STAmount amount{issue, r.second};
|
||||
|
||||
/* If we aren't sending anything or if the sender is the same as the
|
||||
* receiver then we don't need to do anything.
|
||||
@@ -2315,7 +2315,7 @@ static TER
|
||||
accountSendMultiIOU(
|
||||
ApplyView& view,
|
||||
AccountID const& senderID,
|
||||
Asset const& asset,
|
||||
Issue const& issue,
|
||||
MultiplePaymentDestinations const& receivers,
|
||||
beast::Journal j,
|
||||
WaiveTransferFee waiveFee)
|
||||
@@ -2325,27 +2325,14 @@ accountSendMultiIOU(
|
||||
"ripple::accountSendMultiIOU",
|
||||
"multiple recipients provided");
|
||||
|
||||
if (view.rules().enabled(fixAMMv1_1))
|
||||
{
|
||||
if (asset.holds<MPTIssue>())
|
||||
{
|
||||
return tecINTERNAL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
!asset.holds<MPTIssue>(), "ripple::accountSendMultiIOU : not MPT");
|
||||
}
|
||||
|
||||
if (!asset.native())
|
||||
if (!issue.native())
|
||||
{
|
||||
STAmount actual;
|
||||
JLOG(j.trace()) << "accountSendMultiIOU: " << to_string(senderID)
|
||||
<< " sending " << receivers.size() << " IOUs";
|
||||
|
||||
return rippleSendMultiIOU(
|
||||
view, senderID, asset, receivers, actual, j, waiveFee);
|
||||
view, senderID, issue, receivers, actual, j, waiveFee);
|
||||
}
|
||||
|
||||
/* XRP send which does not check reserve and can do pure adjustment.
|
||||
@@ -2370,24 +2357,15 @@ accountSendMultiIOU(
|
||||
}
|
||||
|
||||
// Failures return immediately.
|
||||
STAmount takeFromSender{asset};
|
||||
STAmount takeFromSender{issue};
|
||||
for (auto const& r : receivers)
|
||||
{
|
||||
auto const& receiverID = r.first;
|
||||
STAmount amount{asset, r.second};
|
||||
STAmount amount{issue, r.second};
|
||||
|
||||
if (view.rules().enabled(fixAMMv1_1))
|
||||
if (amount < beast::zero)
|
||||
{
|
||||
if (amount < beast::zero)
|
||||
{
|
||||
return tecINTERNAL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
amount >= beast::zero,
|
||||
"ripple::accountSendMultiIOU : minimum amount");
|
||||
return tecINTERNAL; // LCOV_EXCL_LINE
|
||||
}
|
||||
|
||||
/* If we aren't sending anything or if the sender is the same as the
|
||||
@@ -2603,7 +2581,7 @@ static TER
|
||||
rippleSendMultiMPT(
|
||||
ApplyView& view,
|
||||
AccountID const& senderID,
|
||||
Asset const& asset,
|
||||
MPTIssue const& mptIssue,
|
||||
MultiplePaymentDestinations const& receivers,
|
||||
STAmount& actual,
|
||||
beast::Journal j,
|
||||
@@ -2611,25 +2589,25 @@ rippleSendMultiMPT(
|
||||
{
|
||||
// Safe to get MPT since rippleSendMultiMPT is only called by
|
||||
// accountSendMultiMPT
|
||||
auto const issuer = asset.getIssuer();
|
||||
auto const issuer = mptIssue.getIssuer();
|
||||
|
||||
auto const sle =
|
||||
view.read(keylet::mptIssuance(asset.get<MPTIssue>().getMptID()));
|
||||
auto const sle = view.read(keylet::mptIssuance(mptIssue.getMptID()));
|
||||
if (!sle)
|
||||
return tecOBJECT_NOT_FOUND;
|
||||
|
||||
// These may diverge
|
||||
STAmount takeFromSender{asset};
|
||||
STAmount takeFromSender{mptIssue};
|
||||
actual = takeFromSender;
|
||||
|
||||
for (auto const& r : receivers)
|
||||
{
|
||||
auto const& receiverID = r.first;
|
||||
STAmount amount{asset, r.second};
|
||||
STAmount amount{mptIssue, r.second};
|
||||
|
||||
XRPL_ASSERT(
|
||||
amount >= beast::zero,
|
||||
"ripple::rippleSendMultiMPT : minimum amount ");
|
||||
if (amount < beast::zero)
|
||||
{
|
||||
return tecINTERNAL; // LCOV_EXCL_LINE
|
||||
}
|
||||
|
||||
/* If we aren't sending anything or if the sender is the same as the
|
||||
* receiver then we don't need to do anything.
|
||||
@@ -2720,17 +2698,15 @@ static TER
|
||||
accountSendMultiMPT(
|
||||
ApplyView& view,
|
||||
AccountID const& senderID,
|
||||
Asset const& asset,
|
||||
MPTIssue const& mptIssue,
|
||||
MultiplePaymentDestinations const& receivers,
|
||||
beast::Journal j,
|
||||
WaiveTransferFee waiveFee)
|
||||
{
|
||||
XRPL_ASSERT(asset.holds<MPTIssue>(), "ripple::accountSendMultiMPT : MPT");
|
||||
|
||||
STAmount actual;
|
||||
|
||||
return rippleSendMultiMPT(
|
||||
view, senderID, asset, receivers, actual, j, waiveFee);
|
||||
view, senderID, mptIssue, receivers, actual, j, waiveFee);
|
||||
}
|
||||
|
||||
TER
|
||||
@@ -2771,10 +2747,10 @@ accountSendMulti(
|
||||
[&]<ValidIssueType TIss>(TIss const& issue) {
|
||||
if constexpr (std::is_same_v<TIss, Issue>)
|
||||
return accountSendMultiIOU(
|
||||
view, senderID, asset, receivers, j, waiveFee);
|
||||
view, senderID, issue, receivers, j, waiveFee);
|
||||
else
|
||||
return accountSendMultiMPT(
|
||||
view, senderID, asset, receivers, j, waiveFee);
|
||||
view, senderID, issue, receivers, j, waiveFee);
|
||||
},
|
||||
asset.value());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user