From eca2d619b4459e2f38b5878f8cf57c3b337707c2 Mon Sep 17 00:00:00 2001 From: Gregory Tsipenyuk Date: Mon, 22 Jul 2024 20:41:22 -0400 Subject: [PATCH] Cleanup for consistency with develop and refactoring (mostly XChainBridge.cpp) --- src/xrpld/app/tx/detail/CashCheck.cpp | 6 ++---- src/xrpld/app/tx/detail/Clawback.cpp | 5 ----- src/xrpld/app/tx/detail/XChainBridge.cpp | 20 +++++++++----------- src/xrpld/ledger/detail/View.cpp | 9 +++++---- 4 files changed, 16 insertions(+), 24 deletions(-) diff --git a/src/xrpld/app/tx/detail/CashCheck.cpp b/src/xrpld/app/tx/detail/CashCheck.cpp index 483f1e9ca4d..7118ae1d1c3 100644 --- a/src/xrpld/app/tx/detail/CashCheck.cpp +++ b/src/xrpld/app/tx/detail/CashCheck.cpp @@ -420,15 +420,13 @@ CashCheck::doApply() return tecNO_LINE; SF_AMOUNT const& tweakedLimit = destLow ? sfLowLimit : sfHighLimit; - STAmount const savedLimit = - get(sleTrustLine->at(tweakedLimit)); + STEitherAmount const savedLimit = sleTrustLine->at(tweakedLimit); // Make sure the tweaked limits are restored when we leave scope. scope_exit fixup( [&psb, &trustLineKey, &tweakedLimit, &savedLimit]() { if (auto const sleTrustLine = psb.peek(trustLineKey)) - sleTrustLine->at(tweakedLimit) = - STEitherAmount{savedLimit}; + sleTrustLine->at(tweakedLimit) = savedLimit; }); if (checkCashMakesTrustLine) diff --git a/src/xrpld/app/tx/detail/Clawback.cpp b/src/xrpld/app/tx/detail/Clawback.cpp index 75dc50df052..b7d3862e97f 100644 --- a/src/xrpld/app/tx/detail/Clawback.cpp +++ b/src/xrpld/app/tx/detail/Clawback.cpp @@ -18,12 +18,7 @@ //============================================================================== #include -//#include -//#include -//#include -//#include #include -//#include namespace ripple { diff --git a/src/xrpld/app/tx/detail/XChainBridge.cpp b/src/xrpld/app/tx/detail/XChainBridge.cpp index 9407c5f4ef5..23e9def0716 100644 --- a/src/xrpld/app/tx/detail/XChainBridge.cpp +++ b/src/xrpld/app/tx/detail/XChainBridge.cpp @@ -1387,9 +1387,8 @@ XChainCreateBridge::preflight(PreflightContext const& ctx) return temINVALID_FLAG; auto const account = ctx.tx[sfAccount]; - auto const reward = get(ctx.tx[sfSignatureReward]); - auto const minAccountCreate = - get(ctx.tx[~sfMinAccountCreateAmount]); + auto const reward = ctx.tx[sfSignatureReward]; + auto const minAccountCreate = ctx.tx[~sfMinAccountCreateAmount]; auto const bridgeSpec = ctx.tx[sfXChainBridge]; // Doors must be distinct to help prevent transaction replay attacks if (bridgeSpec.lockingChainDoor() == bridgeSpec.issuingChainDoor()) @@ -1569,9 +1568,8 @@ BridgeModify::preflight(PreflightContext const& ctx) return temINVALID_FLAG; auto const account = ctx.tx[sfAccount]; - auto const reward = get(ctx.tx[~sfSignatureReward]); - auto const minAccountCreate = - get(ctx.tx[~sfMinAccountCreateAmount]); + auto const reward = ctx.tx[~sfSignatureReward]; + auto const minAccountCreate = ctx.tx[~sfMinAccountCreateAmount]; auto const bridgeSpec = ctx.tx[sfXChainBridge]; bool const clearAccountCreate = ctx.tx.getFlags() & tfClearAccountCreateAmount; @@ -2033,7 +2031,7 @@ XChainCreateClaimID::preflight(PreflightContext const& ctx) if (ctx.tx.getFlags() & tfUniversalMask) return temINVALID_FLAG; - auto const reward = get(ctx.tx[sfSignatureReward]); + auto const reward = ctx.tx[sfSignatureReward]; if (!isXRP(reward) || reward.signum() < 0 || !isLegalNet(reward)) return temXCHAIN_BRIDGE_BAD_REWARD_AMOUNT; @@ -2054,9 +2052,9 @@ XChainCreateClaimID::preclaim(PreclaimContext const& ctx) } // Check that the reward matches - auto const reward = get(ctx.tx[sfSignatureReward]); + auto const reward = ctx.tx[sfSignatureReward]; - if (reward != get((*sleBridge)[sfSignatureReward])) + if (reward != (*sleBridge)[sfSignatureReward]) { return tecXCHAIN_REWARD_MISMATCH; } @@ -2208,7 +2206,7 @@ XChainCreateAccountCommit::preclaim(PreclaimContext const& ctx) { STXChainBridge const bridgeSpec = ctx.tx[sfXChainBridge]; STAmount const amount = get(ctx.tx[sfAmount]); - STAmount const reward = get(ctx.tx[sfSignatureReward]); + STEitherAmount const reward = ctx.tx[sfSignatureReward]; auto const sleBridge = readBridge(ctx.view, bridgeSpec); if (!sleBridge) @@ -2216,7 +2214,7 @@ XChainCreateAccountCommit::preclaim(PreclaimContext const& ctx) return tecNO_ENTRY; } - if (reward != get((*sleBridge)[sfSignatureReward])) + if (reward != (*sleBridge)[sfSignatureReward]) { return tecXCHAIN_REWARD_MISMATCH; } diff --git a/src/xrpld/ledger/detail/View.cpp b/src/xrpld/ledger/detail/View.cpp index 7cf05d9cb65..403294d775d 100644 --- a/src/xrpld/ledger/detail/View.cpp +++ b/src/xrpld/ledger/detail/View.cpp @@ -900,8 +900,9 @@ trustCreate( bSetHigh ? sfHighLimit : sfLowLimit, saLimit); sleRippleState->setFieldAmount( bSetHigh ? sfLowLimit : sfHighLimit, - STAmount(Issue{ - saBalance.getCurrency(), bSetDst ? uSrcAccountID : uDstAccountID})); + STAmount( + {saBalance.getCurrency(), + bSetDst ? uSrcAccountID : uDstAccountID})); if (uQualityIn) sleRippleState->setFieldU32( @@ -1135,7 +1136,7 @@ rippleCredit( return tesSUCCESS; } - STAmount const saReceiverLimit(Issue{currency, uReceiverID}); + STAmount const saReceiverLimit({currency, uReceiverID}); STAmount saBalance{saAmount}; saBalance.setIssuer(noAccount()); @@ -1533,7 +1534,7 @@ issueIOU( // NIKB TODO: The limit uses the receiver's account as the issuer and // this is unnecessarily inefficient as copying which could be avoided // is now required. Consider available options. - STAmount const limit(Issue{issue.currency, account}); + STAmount const limit({issue.currency, account}); STAmount final_balance = amount; final_balance.setIssuer(noAccount());