xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
libxrpl
tx
transactors
permissioned_domain
PermissionedDomainDelete.cpp
1
#include <xrpl/tx/transactors/permissioned_domain/PermissionedDomainDelete.h>
2
3
#include <xrpl/basics/Log.h>
4
#include <xrpl/beast/utility/Zero.h>
5
#include <xrpl/beast/utility/instrumentation.h>
6
#include <xrpl/ledger/helpers/AccountRootHelpers.h>
7
#include <xrpl/protocol/Indexes.h>
8
#include <xrpl/protocol/SField.h>
9
#include <xrpl/protocol/STLedgerEntry.h>
10
#include <xrpl/protocol/STTx.h>
11
#include <xrpl/protocol/TER.h>
12
#include <xrpl/protocol/XRPAmount.h>
13
#include <xrpl/tx/Transactor.h>
14
15
namespace
xrpl
{
16
17
NotTEC
18
PermissionedDomainDelete::preflight
(
PreflightContext
const
& ctx)
19
{
20
auto
const
domain = ctx.
tx
.
getFieldH256
(sfDomainID);
21
if
(domain ==
beast::kZero
)
22
return
temMALFORMED
;
23
24
return
tesSUCCESS
;
25
}
26
27
TER
28
PermissionedDomainDelete::preclaim
(
PreclaimContext
const
& ctx)
29
{
30
auto
const
domain = ctx.
tx
.
getFieldH256
(sfDomainID);
31
auto
const
sleDomain = ctx.
view
.
read
(
keylet::permissionedDomain
(domain));
32
33
if
(!sleDomain)
34
return
tecNO_ENTRY
;
35
36
XRPL_ASSERT(
37
sleDomain->isFieldPresent(sfOwner) && ctx.
tx
.
isFieldPresent
(sfAccount),
38
"xrpl::PermissionedDomainDelete::preclaim : required fields present"
);
39
if
(sleDomain->getAccountID(sfOwner) != ctx.
tx
.
getAccountID
(sfAccount))
40
return
tecNO_PERMISSION
;
41
42
return
tesSUCCESS
;
43
}
44
48
TER
49
PermissionedDomainDelete::doApply
()
50
{
51
XRPL_ASSERT(
52
ctx_
.tx.isFieldPresent(sfDomainID),
53
"xrpl::PermissionedDomainDelete::doApply : required field present"
);
54
55
auto
const
slePd =
view
().
peek
(
keylet::permissionedDomain
(
ctx_
.tx.at(sfDomainID)));
56
auto
const
page = (*slePd)[sfOwnerNode];
57
58
if
(!
view
().dirRemove(
keylet::ownerDir
(
accountID_
), page, slePd->
key
(),
true
))
59
{
60
// LCOV_EXCL_START
61
JLOG(
j_
.fatal()) <<
"Unable to delete permissioned domain directory entry."
;
62
return
tefBAD_LEDGER
;
63
// LCOV_EXCL_STOP
64
}
65
66
auto
const
ownerSle =
view
().
peek
(
keylet::account
(
accountID_
));
67
XRPL_ASSERT(
68
ownerSle && ownerSle->getFieldU32(sfOwnerCount) > 0,
69
"xrpl::PermissionedDomainDelete::doApply : nonzero owner count"
);
70
decreaseOwnerCountForObject
(
view
(), ownerSle, slePd, 1,
ctx_
.journal);
71
view
().
erase
(slePd);
72
73
return
tesSUCCESS
;
74
}
75
76
void
77
PermissionedDomainDelete::visitInvariantEntry
(
bool
,
SLE::ConstRef
,
SLE::ConstRef
)
78
{
79
// No transaction-specific invariants yet (future work).
80
}
81
82
bool
83
PermissionedDomainDelete::finalizeInvariants
(
84
STTx
const
&,
85
TER
,
86
XRPAmount
,
87
ReadView
const
&,
88
beast::Journal
const
&)
89
{
90
// No transaction-specific invariants yet (future work).
91
return
true
;
92
}
93
94
}
// namespace xrpl
beast::Journal
A generic endpoint for log messages.
Definition
Journal.h:44
xrpl::ApplyView::peek
virtual SLE::pointer peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
xrpl::ApplyView::erase
virtual void erase(SLE::Ref sle)=0
Remove a peeked SLE.
xrpl::PermissionedDomainDelete::doApply
TER doApply() override
Attempt to delete the Permissioned Domain.
Definition
PermissionedDomainDelete.cpp:49
xrpl::PermissionedDomainDelete::visitInvariantEntry
void visitInvariantEntry(bool isDelete, SLE::ConstRef before, SLE::ConstRef after) override
Inspect a single ledger entry modified by this transaction.
Definition
PermissionedDomainDelete.cpp:77
xrpl::PermissionedDomainDelete::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition
PermissionedDomainDelete.cpp:18
xrpl::PermissionedDomainDelete::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition
PermissionedDomainDelete.cpp:28
xrpl::PermissionedDomainDelete::finalizeInvariants
bool finalizeInvariants(STTx const &tx, TER result, XRPAmount fee, ReadView const &view, beast::Journal const &j) override
Check transaction-specific post-conditions after all entries have been visited.
Definition
PermissionedDomainDelete.cpp:83
xrpl::ReadView
A view into a ledger.
Definition
ReadView.h:41
xrpl::ReadView::read
virtual SLE::const_pointer read(Keylet const &k) const =0
Return the state item associated with a key.
xrpl::STLedgerEntry::ConstRef
std::shared_ptr< STLedgerEntry const > const & ConstRef
Definition
STLedgerEntry.h:37
xrpl::STObject::getFieldH256
UInt256 getFieldH256(SField const &field) const
Definition
STObject.cpp:631
xrpl::STObject::isFieldPresent
bool isFieldPresent(SField const &field) const
Definition
STObject.cpp:464
xrpl::STObject::getAccountID
AccountID getAccountID(SField const &field) const
Definition
STObject.cpp:643
xrpl::STTx
Definition
STTx.h:43
xrpl::Transactor::j_
beast::Journal const j_
Definition
Transactor.h:164
xrpl::Transactor::view
ApplyView & view()
Definition
Transactor.h:184
xrpl::Transactor::accountID_
AccountID const accountID_
Definition
Transactor.h:166
xrpl::Transactor::ctx_
ApplyContext & ctx_
Definition
Transactor.h:162
xrpl::XRPAmount
Definition
XRPAmount.h:28
beast::kZero
constexpr Zero kZero
Definition
Zero.h:30
xrpl::keylet::ownerDir
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Definition
Indexes.cpp:403
xrpl::keylet::permissionedDomain
Keylet permissionedDomain(AccountID const &account, SeqProxy const &seq) noexcept
Definition
Indexes.cpp:609
xrpl::keylet::account
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition
Indexes.cpp:220
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::tefBAD_LEDGER
@ tefBAD_LEDGER
Definition
TER.h:165
xrpl::NotTEC
TERSubset< CanCvtToNotTEC > NotTEC
Definition
TER.h:614
xrpl::decreaseOwnerCountForObject
void decreaseOwnerCountForObject(ApplyView &view, SLE::Ref accountSle, SLE::Ref objectSle, std::uint32_t count, beast::Journal j)
Decrease owner-count fields for an existing ledger object.
Definition
AccountRootHelpers.cpp:359
xrpl::temMALFORMED
@ temMALFORMED
Definition
TER.h:75
xrpl::TER
TERSubset< CanCvtToTER > TER
Definition
TER.h:654
xrpl::tecNO_ENTRY
@ tecNO_ENTRY
Definition
TER.h:314
xrpl::tecNO_PERMISSION
@ tecNO_PERMISSION
Definition
TER.h:313
xrpl::tesSUCCESS
@ tesSUCCESS
Definition
TER.h:250
xrpl::Keylet::key
UInt256 key
Definition
Keylet.h:21
xrpl::PreclaimContext
State information when determining if a tx is likely to claim a fee.
Definition
Transactor.h:92
xrpl::PreclaimContext::view
ReadView const & view
Definition
Transactor.h:95
xrpl::PreclaimContext::tx
STTx const & tx
Definition
Transactor.h:98
xrpl::PreflightContext
State information when preflighting a tx.
Definition
Transactor.h:39
xrpl::PreflightContext::tx
STTx const & tx
Definition
Transactor.h:42
Generated by
1.17.0