Skip to content

Commit

Permalink
refactor based on ED's comment
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterChen13579 committed Jul 27, 2023
1 parent e5fabb8 commit cdbcd37
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/ripple/app/tx/impl/DeleteAccount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <ripple/protocol/Feature.h>
#include <ripple/protocol/Indexes.h>
#include <ripple/protocol/Protocol.h>
#include <ripple/protocol/SystemParameters.h>
#include <ripple/protocol/TxFlags.h>
#include <ripple/protocol/st.h>

Expand Down Expand Up @@ -210,8 +211,7 @@ DeleteAccount::preclaim(PreclaimContext const& ctx)
//
// We look at the account's Sequence rather than the transaction's
// Sequence in preparation for Tickets.
constexpr std::uint32_t seqDelta{255};
if ((*sleAccount)[sfSequence] + seqDelta > ctx.view.seq())
if ((*sleAccount)[sfSequence] + accountDeleteSeqDelta > ctx.view.seq())
return tecTOO_SOON;

// When fixNFTokenRemint is enabled, we don't allow an account to be
Expand All @@ -227,7 +227,8 @@ DeleteAccount::preclaim(PreclaimContext const& ctx)
// authorized minter minted in a previous ledger.
if (ctx.view.rules().enabled(fixNFTokenRemint) &&
((*sleAccount)[~sfFirstNFTokenSequence].value_or(0) +
(*sleAccount)[~sfMintedNFTokens].value_or(0) + seqDelta >
(*sleAccount)[~sfMintedNFTokens].value_or(0) +
accountDeleteSeqDelta >
ctx.view.seq()))
return tecTOO_SOON;

Expand Down
2 changes: 2 additions & 0 deletions src/ripple/protocol/SystemParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ constexpr std::ratio<80, 100> postFixAmendmentMajorityCalcThreshold;
/** The minimum amount of time an amendment must hold a majority */
constexpr std::chrono::seconds const defaultAmendmentMajorityTime = weeks{2};

static constexpr std::uint32_t accountDeleteSeqDelta{255u};

} // namespace ripple

/** Default peer port (IANA registered) */
Expand Down
12 changes: 9 additions & 3 deletions src/ripple/rpc/handlers/AccountTx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <ripple/ledger/ReadView.h>
#include <ripple/net/RPCErr.h>
#include <ripple/protocol/ErrorCodes.h>
#include <ripple/protocol/SystemParameters.h>
#include <ripple/protocol/UintTypes.h>
#include <ripple/protocol/jss.h>
#include <ripple/resource/Fees.h>
Expand Down Expand Up @@ -245,12 +246,17 @@ doAccountTxHelp(RPC::Context& context, AccountTxArgs const& args)
if (context.apiVersion > 1u)
{
bool accountFound = false;
for (unsigned int idx = result.ledgerRange.min;
idx <= result.ledgerRange.max;
++idx)
unsigned int const rangeEnd =
result.ledgerRange.max + AccountDeleteSeqDelta;
for (unsigned int idx = result.ledgerRange.min; idx < rangeEnd;
idx += AccountDeleteSeqDelta)
{
if (idx > result.ledgerRange.max)
idx = result.ledgerRange.max;
std::shared_ptr<ReadView const> ledger;
auto const status = getLedger(ledger, idx, context);
if (status.codeString() == "ledgerNotFound")
continue;
if (ledger->exists(keylet::account(args.account)))
{
accountFound = true;
Expand Down

0 comments on commit cdbcd37

Please sign in to comment.