fix remaining build issues

This commit is contained in:
Mayukha Vadari
2026-03-17 00:54:34 -04:00
parent 5fa9bb53a8
commit ea1146d413
7 changed files with 33 additions and 32 deletions

View File

@@ -61,7 +61,7 @@ public:
//
// @param ownerCountAdj positive to add to count, negative to reduce count.
[[nodiscard]] XRPAmount
xrpLiquid(std::int32_t ownerCountAdj, beast::Journal j);
xrpLiquid(std::int32_t ownerCountAdj, beast::Journal j) const;
/** Adjust the owner count up or down. */
void

View File

@@ -138,16 +138,16 @@ trustCreate(
bool const bSrcHigh,
AccountID const& uSrcAccountID,
AccountID const& uDstAccountID,
uint256 const& uIndex, // --> ripple state entry
WrappedAccountRoot const& wrappedAcct, // --> the account being set.
bool const bAuth, // --> authorize account.
bool const bNoRipple, // --> others cannot ripple through
bool const bFreeze, // --> funds cannot leave
bool bDeepFreeze, // --> can neither receive nor send funds
STAmount const& saBalance, // --> balance of account being set.
// Issuer should be noAccount()
STAmount const& saLimit, // --> limit for account being set.
// Issuer should be the account being set.
uint256 const& uIndex, // --> ripple state entry
WrappedAccountRoot& wrappedAcct, // --> the account being set.
bool const bAuth, // --> authorize account.
bool const bNoRipple, // --> others cannot ripple through
bool const bFreeze, // --> funds cannot leave
bool bDeepFreeze, // --> can neither receive nor send funds
STAmount const& saBalance, // --> balance of account being set.
// Issuer should be noAccount()
STAmount const& saLimit, // --> limit for account being set.
// Issuer should be the account being set.
std::uint32_t uQualityIn,
std::uint32_t uQualityOut,
beast::Journal j);

View File

@@ -1,5 +1,7 @@
#pragma once
#include <xrpl/ledger/ApplyView.h>
#include <xrpl/ledger/ReadView.h>
#include <xrpl/protocol/STLedgerEntry.h>
#include <memory>
@@ -7,9 +9,6 @@
namespace xrpl {
class ReadView;
class ApplyView;
/**
* Base class for all ledger entry view classes.
*
@@ -78,7 +77,7 @@ public:
bool
canModify() const
{
return applyView_ != nullptr;
return applyView_ != nullptr && mutableSle_ != nullptr;
}
/** Returns the apply view for write operations
@@ -98,6 +97,7 @@ public:
STLedgerEntry*
operator->()
{
XRPL_ASSERT(canModify(), "xrpl::WrappedSLEBase::operator* : can modify");
return mutableSle_.get();
}
@@ -110,6 +110,7 @@ public:
STLedgerEntry&
operator*()
{
XRPL_ASSERT(canModify(), "xrpl::WrappedSLEBase::operator* : can modify");
return *mutableSle_;
}

View File

@@ -62,7 +62,7 @@ confineOwnerCount(
}
XRPAmount
WrappedAccountRoot::xrpLiquid(std::int32_t ownerCountAdj, beast::Journal j)
WrappedAccountRoot::xrpLiquid(std::int32_t ownerCountAdj, beast::Journal j) const
{
// Return balance minus reserve
std::uint32_t const ownerCount = confineOwnerCount(
@@ -99,16 +99,14 @@ WrappedAccountRoot::transferRate() const
void
WrappedAccountRoot::adjustOwnerCount(std::int32_t amount, beast::Journal j)
{
if (!sle_)
return;
XRPL_ASSERT(canModify(), "xrpl::adjustOwnerCount : can modify");
XRPL_ASSERT(amount, "xrpl::adjustOwnerCount : nonzero amount input");
std::uint32_t const current{sle_->getFieldU32(sfOwnerCount)};
AccountID const id = (*sle_)[sfAccount];
std::uint32_t const current{mutableSle_->getFieldU32(sfOwnerCount)};
AccountID const id = (*mutableSle_)[sfAccount];
std::uint32_t const adjusted = confineOwnerCount(current, amount, id, j);
applyView_->adjustOwnerCountHook(id_, current, adjusted);
auto mutable_sle = mutableSle();
mutable_sle->at(sfOwnerCount) = adjusted;
applyView_->update(mutable_sle);
mutableSle_->at(sfOwnerCount) = adjusted;
applyView_->update(mutableSle_);
}
AccountID

View File

@@ -424,7 +424,7 @@ issueIOU(
final_balance.setIssuer(noAccount());
WrappedAccountRoot const receiverAccount(account, &view);
WrappedAccountRoot receiverAccount(account, &view);
if (!receiverAccount)
return tefINTERNAL; // LCOV_EXCL_LINE

View File

@@ -260,17 +260,17 @@ class Invariants_test : public beast::unit_test::suite
[&](Account const& A1, Account const& A2, ApplyContext& ac) {
// Increment A1's owner count, then delete A1
auto const a1 = A1.id();
auto const sleA1 = ac.view().peek(keylet::account(a1));
if (!sleA1)
WrappedAccountRoot wrappedA1(a1, &ac.view());
if (!wrappedA1)
return false;
// Clear the balance so the "account deletion left behind a
// non-zero balance" check doesn't trip earlier than the desired
// check.
sleA1->at(sfBalance) = beast::zero;
BEAST_EXPECT(sleA1->at(sfOwnerCount) == 0);
adjustOwnerCount(ac.view(), sleA1, 1, ac.journal);
wrappedA1->at(sfBalance) = beast::zero;
BEAST_EXPECT(wrappedA1->at(sfOwnerCount) == 0);
wrappedA1.adjustOwnerCount(1, ac.journal);
ac.view().erase(sleA1);
ac.view().erase(wrappedA1.mutableSle());
return true;
},

View File

@@ -844,13 +844,15 @@ class View_test : public beast::unit_test::suite
auto rdView = env.closed();
// Test with no rate set on gw1.
BEAST_EXPECT(transferRate(*rdView, gw1) == parityRate);
WrappedAccountRoot issuer(gw1, rdView.get());
BEAST_EXPECT(issuer.transferRate() == parityRate);
env(rate(gw1, 1.02));
env.close();
rdView = env.closed();
BEAST_EXPECT(transferRate(*rdView, gw1) == Rate{1020000000});
WrappedAccountRoot issuerV2(gw1, rdView.get());
BEAST_EXPECT(issuerV2.transferRate() == Rate{1020000000});
}
void