rippled
Loading...
Searching...
No Matches
DIDDelete.cpp
1#include <xrpl/basics/Log.h>
2#include <xrpl/ledger/ApplyView.h>
3#include <xrpl/ledger/helpers/AccountRootHelpers.h>
4#include <xrpl/protocol/Indexes.h>
5#include <xrpl/tx/transactors/did/DIDDelete.h>
6
7namespace xrpl {
8
11{
12 return tesSUCCESS;
13}
14
15TER
17{
18 auto const sle = ctx.view().peek(sleKeylet);
19 if (!sle)
20 return tecNO_ENTRY;
21
22 return DIDDelete::deleteSLE(ctx.view(), sle, owner, ctx.journal);
23}
24
25TER
27 ApplyView& view,
29 AccountID const owner,
31{
32 // Remove object from owner directory
33 if (!view.dirRemove(keylet::ownerDir(owner), (*sle)[sfOwnerNode], sle->key(), true))
34 {
35 // LCOV_EXCL_START
36 JLOG(j.fatal()) << "Unable to delete DID from owner.";
37 return tefBAD_LEDGER;
38 // LCOV_EXCL_STOP
39 }
40
41 auto const sleOwner = view.peek(keylet::account(owner));
42 if (!sleOwner)
43 return tecINTERNAL; // LCOV_EXCL_LINE
44
45 adjustOwnerCount(view, sleOwner, -1, j);
46 view.update(sleOwner);
47
48 // Remove object from ledger
49 view.erase(sle);
50 return tesSUCCESS;
51}
52
53TER
58
59} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:40
Stream fatal() const
Definition Journal.h:325
State information when applying a tx.
beast::Journal const journal
ApplyView & view()
Writeable view to a ledger, for applying a transaction.
Definition ApplyView.h:116
virtual void update(std::shared_ptr< SLE > const &sle)=0
Indicate changes to a peeked SLE.
bool dirRemove(Keylet const &directory, std::uint64_t page, uint256 const &key, bool keepRoot)
Remove an entry from a directory.
virtual void erase(std::shared_ptr< SLE > const &sle)=0
Remove a peeked SLE.
virtual std::shared_ptr< SLE > peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
static NotTEC preflight(PreflightContext const &ctx)
Definition DIDDelete.cpp:10
TER doApply() override
Definition DIDDelete.cpp:54
static TER deleteSLE(ApplyContext &ctx, Keylet sleKeylet, AccountID const owner)
Definition DIDDelete.cpp:16
AccountID const account_
Definition Transactor.h:116
ApplyView & view()
Definition Transactor.h:132
ApplyContext & ctx_
Definition Transactor.h:112
Keylet did(AccountID const &account) noexcept
Definition Indexes.cpp:462
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Definition Indexes.cpp:336
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition Indexes.cpp:165
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
@ tefBAD_LEDGER
Definition TER.h:150
void adjustOwnerCount(ApplyView &view, std::shared_ptr< SLE > const &sle, std::int32_t amount, beast::Journal j)
Adjust the owner count up or down.
@ tecNO_ENTRY
Definition TER.h:287
@ tecINTERNAL
Definition TER.h:291
TERSubset< CanCvtToNotTEC > NotTEC
Definition TER.h:582
@ tesSUCCESS
Definition TER.h:225
A pair of SHAMap key and LedgerEntryType.
Definition Keylet.h:19
State information when preflighting a tx.
Definition Transactor.h:14