xrpld
Loading...
Searching...
No Matches
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
19namespace xrpl {
20
23{
24 return tesSUCCESS;
25}
26
27TER
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
37TER
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 adjustOwnerCount(view, sleOwner, -1, j);
54 view.update(sleOwner);
55
56 // Remove object from ledger
57 view.erase(sle);
58 return tesSUCCESS;
59}
60
61TER
66
67void
69{
70 // No transaction-specific invariants yet (future work).
71}
72
73bool
75{
76 // No transaction-specific invariants yet (future work).
77 return true;
78}
79} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:38
Stream fatal() const
Definition Journal.h:321
State information when applying a tx.
beast::Journal const journal
ApplyView & view()
Writeable view to a ledger, for applying a transaction.
Definition ApplyView.h:118
virtual SLE::pointer peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
static NotTEC preflight(PreflightContext const &ctx)
Definition DIDDelete.cpp:22
void visitInvariantEntry(bool isDelete, SLE::const_ref before, SLE::const_ref after) override
Inspect a single ledger entry modified by this transaction.
Definition DIDDelete.cpp:68
TER doApply() override
Definition DIDDelete.cpp:62
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:74
static TER deleteSLE(ApplyContext &ctx, Keylet sleKeylet, AccountID const owner)
Definition DIDDelete.cpp:28
A view into a ledger.
Definition ReadView.h:31
std::shared_ptr< STLedgerEntry > pointer
std::shared_ptr< STLedgerEntry const > const & const_ref
ApplyView & view()
Definition Transactor.h:136
AccountID const accountID_
Definition Transactor.h:120
ApplyContext & ctx_
Definition Transactor.h:116
Keylet did(AccountID const &account) noexcept
Definition Indexes.cpp:509
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Definition Indexes.cpp:357
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition Indexes.cpp:186
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
@ tefBAD_LEDGER
Definition TER.h:160
TERSubset< CanCvtToNotTEC > NotTEC
Definition TER.h:594
void adjustOwnerCount(ApplyView &view, SLE::ref sle, std::int32_t amount, beast::Journal j)
Adjust the owner count up or down.
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:28
TERSubset< CanCvtToTER > TER
Definition TER.h:634
@ tecNO_ENTRY
Definition TER.h:304
@ tecINTERNAL
Definition TER.h:308
@ tesSUCCESS
Definition TER.h:240
A pair of SHAMap key and LedgerEntryType.
Definition Keylet.h:19
State information when preflighting a tx.
Definition Transactor.h:18