xrpld
Loading...
Searching...
No Matches
ApplyStateTable.h
1#pragma once
2
3#include <xrpl/beast/utility/Journal.h>
4#include <xrpl/ledger/OpenView.h>
5#include <xrpl/ledger/RawView.h>
6#include <xrpl/ledger/ReadView.h>
7#include <xrpl/protocol/TER.h>
8#include <xrpl/protocol/TxMeta.h>
9#include <xrpl/protocol/XRPAmount.h>
10
11namespace xrpl::detail {
12
13// Helper class that buffers modifications
15{
16public:
18
19private:
20 enum class Action {
25 };
26
28
31
32public:
33 ApplyStateTable() = default;
35
40 operator=(ApplyStateTable const&) = delete;
41
42 void
43 apply(RawView& to) const;
44
46 apply(
47 OpenView& to,
48 STTx const& tx,
49 TER ter,
50 std::optional<STAmount> const& deliver,
51 std::optional<uint256 const> const& parentBatchId,
52 bool isDryRun,
54
55 [[nodiscard]] bool
56 exists(ReadView const& base, Keylet const& k) const;
57
58 [[nodiscard]] std::optional<key_type>
59 succ(ReadView const& base, key_type const& key, std::optional<key_type> const& last) const;
60
61 [[nodiscard]] SLE::const_pointer
62 read(ReadView const& base, Keylet const& k) const;
63
65 peek(ReadView const& base, Keylet const& k);
66
67 [[nodiscard]] std::size_t
68 size() const;
69
70 void
71 visit(
72 ReadView const& base,
73 std::function<void(
74 uint256 const& key,
75 bool isDelete,
76 SLE::const_ref before,
77 SLE::const_ref after)> const& func) const;
78
79 void
80 erase(ReadView const& base, SLE::ref sle);
81
82 void
83 rawErase(ReadView const& base, SLE::ref sle);
84
85 void
86 insert(ReadView const& base, SLE::ref sle);
87
88 void
89 update(ReadView const& base, SLE::ref sle);
90
91 void
92 replace(ReadView const& base, SLE::ref sle);
93
94 void
95 destroyXRP(XRPAmount const& fee);
96
97 // For debugging
98 [[nodiscard]] XRPAmount const&
100 {
101 return dropsDestroyed_;
102 }
103
104private:
106
107 static void
108 threadItem(TxMeta& meta, SLE::ref to);
109
111 getForMod(ReadView const& base, key_type const& key, Mods& mods, beast::Journal j);
112
113 void
114 threadTx(ReadView const& base, TxMeta& meta, AccountID const& to, Mods& mods, beast::Journal j);
115
116 void
118 ReadView const& base,
119 TxMeta& meta,
120 SLE::const_ref sle,
121 Mods& mods,
123};
124
125} // namespace xrpl::detail
A generic endpoint for log messages.
Definition Journal.h:38
Writable ledger view that accumulates state and tx changes.
Definition OpenView.h:45
Interface for ledger entry changes.
Definition RawView.h:14
A view into a ledger.
Definition ReadView.h:31
uint256 key_type
Definition ReadView.h:35
std::shared_ptr< STLedgerEntry > const & ref
std::shared_ptr< STLedgerEntry > pointer
std::shared_ptr< STLedgerEntry const > const & const_ref
std::shared_ptr< STLedgerEntry const > const_pointer
SLE::const_pointer read(ReadView const &base, Keylet const &k) const
void destroyXRP(XRPAmount const &fee)
bool exists(ReadView const &base, Keylet const &k) const
std::map< key_type, std::pair< Action, SLE::pointer > > items_t
void replace(ReadView const &base, SLE::ref sle)
XRPAmount const & dropsDestroyed() const
void insert(ReadView const &base, SLE::ref sle)
void visit(ReadView const &base, std::function< void(uint256 const &key, bool isDelete, SLE::const_ref before, SLE::const_ref after)> const &func) const
SLE::pointer peek(ReadView const &base, Keylet const &k)
SLE::pointer getForMod(ReadView const &base, key_type const &key, Mods &mods, beast::Journal j)
std::optional< key_type > succ(ReadView const &base, key_type const &key, std::optional< key_type > const &last) const
void threadTx(ReadView const &base, TxMeta &meta, AccountID const &to, Mods &mods, beast::Journal j)
void threadOwners(ReadView const &base, TxMeta &meta, SLE::const_ref sle, Mods &mods, beast::Journal j)
ApplyStateTable & operator=(ApplyStateTable const &)=delete
void rawErase(ReadView const &base, SLE::ref sle)
void apply(RawView &to) const
void update(ReadView const &base, SLE::ref sle)
ApplyStateTable & operator=(ApplyStateTable &&)=delete
hash_map< key_type, SLE::pointer > Mods
static void threadItem(TxMeta &meta, SLE::ref to)
ApplyStateTable(ApplyStateTable const &)=delete
ApplyStateTable(ApplyStateTable &&)=default
void erase(ReadView const &base, SLE::ref sle)
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
Definition View.cpp:554
std::unordered_map< Key, Value, Hash, Pred, Allocator > hash_map
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
BaseUInt< 256 > uint256
Definition base_uint.h:562
A pair of SHAMap key and LedgerEntryType.
Definition Keylet.h:19