xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
libxrpl
tx
transactors
did
DIDDelete.cpp
1
#include <xrpl/tx/transactors/did/DIDDelete.h>
2
3
#include <xrpl/basics/Log.h>
4
#include <xrpl/core/ServiceRegistry.h>
5
#include <xrpl/ledger/ApplyView.h>
6
#include <xrpl/ledger/ReadView.h>
7
#include <xrpl/ledger/helpers/AccountRootHelpers.h>
8
#include <xrpl/protocol/AccountID.h>
9
#include <xrpl/protocol/Indexes.h>
10
#include <xrpl/protocol/Keylet.h>
11
#include <xrpl/protocol/SField.h>
12
#include <xrpl/protocol/STLedgerEntry.h>
13
#include <xrpl/protocol/STTx.h>
14
#include <xrpl/protocol/TER.h>
15
#include <xrpl/protocol/XRPAmount.h>
16
#include <xrpl/tx/ApplyContext.h>
17
#include <xrpl/tx/Transactor.h>
18
19
namespace
xrpl
{
20
21
NotTEC
22
DIDDelete::preflight
(
PreflightContext
const
& ctx)
23
{
24
return
tesSUCCESS
;
25
}
26
27
TER
28
DIDDelete::deleteSLE
(
ApplyContext
& ctx,
Keylet
sleKeylet,
AccountID
const
owner)
29
{
30
auto
const
sle = ctx.
view
().
peek
(sleKeylet);
31
if
(!sle)
32
return
tecNO_ENTRY
;
33
34
return
DIDDelete::deleteSLE
(ctx.
view
(), sle, owner, ctx.
journal
);
35
}
36
37
TER
38
DIDDelete::deleteSLE
(
ApplyView
&
view
,
SLE::pointer
sle,
AccountID
const
owner,
beast::Journal
j)
39
{
40
// Remove object from owner directory
41
if
(!
view
.dirRemove(
keylet::ownerDir
(owner), (*sle)[sfOwnerNode], sle->key(),
true
))
42
{
43
// LCOV_EXCL_START
44
JLOG(j.
fatal
()) <<
"Unable to delete DID from owner."
;
45
return
tefBAD_LEDGER
;
46
// LCOV_EXCL_STOP
47
}
48
49
auto
const
sleOwner =
view
.peek(
keylet::account
(owner));
50
if
(!sleOwner)
51
return
tecINTERNAL
;
// LCOV_EXCL_LINE
52
53
decreaseOwnerCountForObject
(
view
, sleOwner, sle, 1, j);
54
55
// Remove object from ledger
56
view
.erase(sle);
57
return
tesSUCCESS
;
58
}
59
60
TER
61
DIDDelete::doApply
()
62
{
63
return
deleteSLE
(
ctx_
,
keylet::did
(
accountID_
),
accountID_
);
64
}
65
66
void
67
DIDDelete::visitInvariantEntry
(
bool
,
SLE::ConstRef
,
SLE::ConstRef
)
68
{
69
// No transaction-specific invariants yet (future work).
70
}
71
72
bool
73
DIDDelete::finalizeInvariants
(
STTx
const
&,
TER
,
XRPAmount
,
ReadView
const
&,
beast::Journal
const
&)
74
{
75
// No transaction-specific invariants yet (future work).
76
return
true
;
77
}
78
}
// namespace xrpl
beast::Journal
A generic endpoint for log messages.
Definition
Journal.h:44
beast::Journal::fatal
Stream fatal() const
Definition
Journal.h:368
xrpl::ApplyContext
State information when applying a tx.
Definition
ApplyContext.h:28
xrpl::ApplyContext::journal
beast::Journal const journal
Definition
ApplyContext.h:61
xrpl::ApplyContext::view
ApplyView & view()
Definition
ApplyContext.h:64
xrpl::ApplyView
Writeable view to a ledger, for applying a transaction.
Definition
ApplyView.h:141
xrpl::ApplyView::peek
virtual SLE::pointer peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
xrpl::DIDDelete::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition
DIDDelete.cpp:22
xrpl::DIDDelete::visitInvariantEntry
void visitInvariantEntry(bool isDelete, SLE::ConstRef before, SLE::ConstRef after) override
Inspect a single ledger entry modified by this transaction.
Definition
DIDDelete.cpp:67
xrpl::DIDDelete::doApply
TER doApply() override
Definition
DIDDelete.cpp:61
xrpl::DIDDelete::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
DIDDelete.cpp:73
xrpl::DIDDelete::deleteSLE
static TER deleteSLE(ApplyContext &ctx, Keylet sleKeylet, AccountID const owner)
Definition
DIDDelete.cpp:28
xrpl::ReadView
A view into a ledger.
Definition
ReadView.h:41
xrpl::STLedgerEntry::pointer
std::shared_ptr< STLedgerEntry > pointer
Definition
STLedgerEntry.h:34
xrpl::STLedgerEntry::ConstRef
std::shared_ptr< STLedgerEntry const > const & ConstRef
Definition
STLedgerEntry.h:37
xrpl::STTx
Definition
STTx.h:43
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
xrpl::keylet::did
Keylet did(AccountID const &account) noexcept
Definition
Indexes.cpp:555
xrpl::keylet::ownerDir
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Definition
Indexes.cpp:403
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::AccountID
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition
AccountID.h:34
xrpl::TER
TERSubset< CanCvtToTER > TER
Definition
TER.h:654
xrpl::tecNO_ENTRY
@ tecNO_ENTRY
Definition
TER.h:314
xrpl::tecINTERNAL
@ tecINTERNAL
Definition
TER.h:318
xrpl::tesSUCCESS
@ tesSUCCESS
Definition
TER.h:250
xrpl::Keylet
A pair of SHAMap key and LedgerEntryType.
Definition
Keylet.h:20
xrpl::PreflightContext
State information when preflighting a tx.
Definition
Transactor.h:39
Generated by
1.17.0