mirror of
https://github.com/XRPLF/rippled.git
synced 2026-07-30 18:40:28 +00:00
more progress
This commit is contained in:
@@ -407,7 +407,7 @@ struct ReserveContext
|
||||
SLE::pointer sponsorshipSle;
|
||||
|
||||
bool
|
||||
isSponsored()
|
||||
isSponsored() const
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
sponsorID.has_value() == !!sponsorSle,
|
||||
@@ -416,7 +416,7 @@ struct ReserveContext
|
||||
}
|
||||
|
||||
bool
|
||||
hasSponsorshipObj()
|
||||
hasSponsorshipObj() const
|
||||
{
|
||||
return !!sponsorshipSle;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ findTokenAndPage(ApplyView& view, AccountID const& owner, uint256 const& nftoken
|
||||
|
||||
/** Insert the token in the owner's token directory. */
|
||||
TER
|
||||
insertToken(ApplyView& view, AccountID owner, STObject&& nft);
|
||||
insertToken(ApplyViewContext& view, AccountID owner, STObject&& nft);
|
||||
|
||||
/** Remove the token from the owner's token directory. */
|
||||
TER
|
||||
|
||||
@@ -416,17 +416,20 @@ ApplyView::dirDelete(Keylet const& directory, std::function<void(uint256 const&)
|
||||
return true;
|
||||
}
|
||||
|
||||
static ReserveContext
|
||||
ReserveContext
|
||||
ReserveContext::makeFromObject(ApplyView& view, SLE::ref objectSle, SLE::pointer ownerSle)
|
||||
{
|
||||
auto const accountID = ownerSle->getAccountID(sfAccount);
|
||||
SLE::ref sponsorSle = getLedgerEntryReserveSponsor(view, objectSle);
|
||||
std::optional<AccountID> const sponsorID =
|
||||
sponsorSle ? sponsorSle->getAccountID(sfAccount) : std::nullopt;
|
||||
return
|
||||
{
|
||||
ownerSle->getAccountID(sfAccount), ownerSle, sponsorID, sponsorSle,
|
||||
sponsorID ? view.peek(keylet::sponsorship(*sponsorID, account)) : nullptr,
|
||||
}
|
||||
sponsorSle ? std::optional<AccountID>{sponsorSle->getAccountID(sfAccount)} : std::nullopt;
|
||||
return {
|
||||
accountID,
|
||||
ownerSle,
|
||||
sponsorID,
|
||||
sponsorSle,
|
||||
sponsorID ? view.peek(keylet::sponsorship(*sponsorID, accountID)) : nullptr,
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -215,7 +215,7 @@ adjustOwnerCountValue(
|
||||
void
|
||||
adjustOwnerCountImpl(
|
||||
ApplyView& view,
|
||||
ReserveContext& reserveCtx,
|
||||
ReserveContext const& reserveCtx,
|
||||
std::int32_t ownerCountAdj,
|
||||
beast::Journal j)
|
||||
{
|
||||
@@ -240,14 +240,14 @@ adjustOwnerCountImpl(
|
||||
Throw<std::logic_error>("xrpl::adjustOwnerCount : valid sponsor sle type");
|
||||
|
||||
adjustOwnerCountValue(
|
||||
ctx.view,
|
||||
view,
|
||||
reserveCtx.accountSle,
|
||||
sfSponsoredOwnerCount,
|
||||
reserveCtx.accountID,
|
||||
ownerCountAdj,
|
||||
j);
|
||||
adjustOwnerCountValue(
|
||||
ctx.view,
|
||||
view,
|
||||
reserveCtx.sponsorSle,
|
||||
sfSponsoringOwnerCount,
|
||||
*reserveCtx.sponsorID,
|
||||
@@ -260,7 +260,7 @@ adjustOwnerCountImpl(
|
||||
// Remaining owner count moves opposite to ownerCountAdj:
|
||||
// +ownerCountAdj => consume reserve (-),
|
||||
adjustOwnerCountValue(
|
||||
ctx.view,
|
||||
view,
|
||||
reserveCtx.sponsorshipSle,
|
||||
sfRemainingOwnerCount,
|
||||
*reserveCtx.sponsorID,
|
||||
@@ -270,20 +270,20 @@ adjustOwnerCountImpl(
|
||||
}
|
||||
}
|
||||
adjustOwnerCountValue(
|
||||
ctx.view, reserveCtx.accountSle, sfOwnerCount, reserveCtx.accountID, ownerCountAdj, j);
|
||||
view, reserveCtx.accountSle, sfOwnerCount, reserveCtx.accountID, ownerCountAdj, j);
|
||||
}
|
||||
|
||||
void
|
||||
adjustOwnerCount(ApplyViewContext& ctx, std::int32_t ownerCountAdj, beast::Journal j)
|
||||
{
|
||||
return adjustOwnerCountImpl(ctx.view, ctx.reserveCtx, ownerCountAdj, j);
|
||||
return adjustOwnerCountImpl(ctx.view, ctx.reserveContext, ownerCountAdj, j);
|
||||
}
|
||||
|
||||
void
|
||||
adjustOwnerCountObj(
|
||||
ApplyViewContext& ctx,
|
||||
SLE::ref objectSle,
|
||||
std::int32_t accountCountAdj,
|
||||
std::int32_t ownerCountAdj,
|
||||
beast::Journal j)
|
||||
{
|
||||
if (!objectSle)
|
||||
@@ -291,11 +291,10 @@ adjustOwnerCountObj(
|
||||
if (objectSle->getType() == ltACCOUNT_ROOT)
|
||||
Throw<std::logic_error>("xrpl::adjustOwnerCount : valid object sle type");
|
||||
|
||||
SLE::ref sponsorSle = getLedgerEntryReserveSponsor(ctx.view, objectSle);
|
||||
adjustOwnerCountImpl(
|
||||
ctx.view,
|
||||
ReserveContext::makeFromObj(ctx.view, objectSle, ctx.reserveCtx.accountSle),
|
||||
amount,
|
||||
ReserveContext::makeFromObject(ctx.view, objectSle, ctx.reserveContext.accountSle),
|
||||
ownerCountAdj,
|
||||
j);
|
||||
}
|
||||
|
||||
|
||||
@@ -69,11 +69,12 @@ locatePage(ApplyView& view, AccountID const& owner, uint256 const& id)
|
||||
|
||||
static SLE::pointer
|
||||
getPageForToken(
|
||||
ApplyView& view,
|
||||
ApplyViewContext& ctx,
|
||||
AccountID const& owner,
|
||||
uint256 const& id,
|
||||
std::function<void(ApplyView&, AccountID const&)> const& createCallback)
|
||||
std::function<void(ApplyViewContext&, AccountID const&)> const& createCallback)
|
||||
{
|
||||
auto& view = ctx.view;
|
||||
auto const base = keylet::nftpageMin(owner);
|
||||
auto const first = keylet::nftpage(base, id);
|
||||
auto const last = keylet::nftpageMax(owner);
|
||||
@@ -91,7 +92,7 @@ getPageForToken(
|
||||
cp = std::make_shared<SLE>(last);
|
||||
cp->setFieldArray(sfNFTokens, arr);
|
||||
view.insert(cp);
|
||||
createCallback(view, owner);
|
||||
createCallback(ctx, owner);
|
||||
return cp;
|
||||
}
|
||||
|
||||
@@ -260,16 +261,16 @@ changeTokenURI(
|
||||
|
||||
/** Insert the token in the owner's token directory. */
|
||||
TER
|
||||
insertToken(ApplyView& view, AccountID owner, STObject&& nft)
|
||||
insertToken(ApplyViewContext& ctx, AccountID owner, STObject&& nft)
|
||||
{
|
||||
XRPL_ASSERT(nft.isFieldPresent(sfNFTokenID), "xrpl::nft::insertToken : has NFT token");
|
||||
|
||||
// First, we need to locate the page the NFT belongs to, creating it
|
||||
// if necessary. This operation may fail if it is impossible to insert
|
||||
// the NFT.
|
||||
SLE::pointer const page =
|
||||
getPageForToken(view, owner, nft[sfNFTokenID], [](ApplyView& view, AccountID const& owner) {
|
||||
adjustOwnerCount(view, owner, {}, 1, beast::Journal{beast::Journal::getNullSink()});
|
||||
SLE::pointer const page = getPageForToken(
|
||||
ctx, owner, nft[sfNFTokenID], [](ApplyViewContext& ctx, AccountID const& owner) {
|
||||
adjustOwnerCount(ctx, owner, {}, 1, beast::Journal{beast::Journal::getNullSink()});
|
||||
});
|
||||
|
||||
if (!page)
|
||||
|
||||
@@ -21,6 +21,7 @@ offerDelete(ApplyViewContext& ctx, SLE::ref sle, beast::Journal j)
|
||||
return tesSUCCESS;
|
||||
auto offerIndex = sle->key();
|
||||
auto owner = sle->getAccountID(sfAccount);
|
||||
auto& view = ctx.view();
|
||||
|
||||
// Detect legacy directories.
|
||||
uint256 const uDirectory = sle->getFieldH256(sfBookDirectory);
|
||||
|
||||
@@ -551,7 +551,7 @@ canTransfer(
|
||||
// --> bCheckIssuer : normally require issuer to be involved.
|
||||
static TER
|
||||
directSendNoFeeIOU(
|
||||
ApplyView& view,
|
||||
ApplyViewContext& ctx,
|
||||
AccountID const& uSenderID,
|
||||
AccountID const& uReceiverID,
|
||||
STAmount const& saAmount,
|
||||
@@ -629,7 +629,7 @@ directSendNoFeeIOU(
|
||||
// Clear the reserve of the sender, possibly delete the line!
|
||||
auto const currentSponsor = getLedgerEntryReserveSponsor(
|
||||
view, sleRippleState, !bSenderHigh ? sfLowSponsor : sfHighSponsor);
|
||||
adjustOwnerCountObj(view, view.peek(keylet::account(uSenderID)), currentSponsor, -1, j);
|
||||
adjustOwnerCountObj(ctx, currentSponsor, -1, j);
|
||||
|
||||
removeSponsorFromLedgerEntry(
|
||||
sleRippleState, !bSenderHigh ? sfLowSponsor : sfHighSponsor);
|
||||
|
||||
Reference in New Issue
Block a user