rippled
Loading...
Searching...
No Matches
ApplyStateTable.h
1#ifndef XRPL_LEDGER_APPLYSTATETABLE_H_INCLUDED
2#define XRPL_LEDGER_APPLYSTATETABLE_H_INCLUDED
3
4#include <xrpl/beast/utility/Journal.h>
5#include <xrpl/ledger/OpenView.h>
6#include <xrpl/ledger/RawView.h>
7#include <xrpl/ledger/ReadView.h>
8#include <xrpl/protocol/TER.h>
9#include <xrpl/protocol/TxMeta.h>
10#include <xrpl/protocol/XRPAmount.h>
11
12#include <memory>
13
14namespace ripple {
15namespace detail {
16
17// Helper class that buffers modifications
19{
20public:
22
23private:
24 enum class Action {
25 cache,
26 erase,
27 insert,
28 modify,
29 };
30
32
35
36public:
37 ApplyStateTable() = default;
39
44 operator=(ApplyStateTable const&) = delete;
45
46 void
47 apply(RawView& to) const;
48
50 apply(
51 OpenView& to,
52 STTx const& tx,
53 TER ter,
54 std::optional<STAmount> const& deliver,
55 std::optional<uint256 const> const& parentBatchId,
56 bool isDryRun,
58
59 bool
60 exists(ReadView const& base, Keylet const& k) const;
61
63 succ(
64 ReadView const& base,
65 key_type const& key,
66 std::optional<key_type> const& last) const;
67
69 read(ReadView const& base, Keylet const& k) const;
70
72 peek(ReadView const& base, Keylet const& k);
73
75 size() const;
76
77 void
78 visit(
79 ReadView const& base,
80 std::function<void(
81 uint256 const& key,
82 bool isDelete,
83 std::shared_ptr<SLE const> const& before,
84 std::shared_ptr<SLE const> const& after)> const& func) const;
85
86 void
87 erase(ReadView const& base, std::shared_ptr<SLE> const& sle);
88
89 void
90 rawErase(ReadView const& base, std::shared_ptr<SLE> const& sle);
91
92 void
93 insert(ReadView const& base, std::shared_ptr<SLE> const& sle);
94
95 void
96 update(ReadView const& base, std::shared_ptr<SLE> const& sle);
97
98 void
99 replace(ReadView const& base, std::shared_ptr<SLE> const& sle);
100
101 void
102 destroyXRP(XRPAmount const& fee);
103
104 // For debugging
105 XRPAmount const&
107 {
108 return dropsDestroyed_;
109 }
110
111private:
113
114 static void
115 threadItem(TxMeta& meta, std::shared_ptr<SLE> const& to);
116
118 getForMod(
119 ReadView const& base,
120 key_type const& key,
121 Mods& mods,
123
124 void
125 threadTx(
126 ReadView const& base,
127 TxMeta& meta,
128 AccountID const& to,
129 Mods& mods,
131
132 void
134 ReadView const& base,
135 TxMeta& meta,
137 Mods& mods,
139};
140
141} // namespace detail
142} // namespace ripple
143
144#endif
A generic endpoint for log messages.
Definition Journal.h:41
Writable ledger view that accumulates state and tx changes.
Definition OpenView.h:46
Interface for ledger entry changes.
Definition RawView.h:15
A view into a ledger.
Definition ReadView.h:32
uint256 key_type
Definition ReadView.h:37
std::shared_ptr< SLE > peek(ReadView const &base, Keylet const &k)
void rawErase(ReadView const &base, std::shared_ptr< SLE > const &sle)
XRPAmount const & dropsDestroyed() const
void threadTx(ReadView const &base, TxMeta &meta, AccountID const &to, Mods &mods, beast::Journal j)
std::shared_ptr< SLE const > read(ReadView const &base, Keylet const &k) const
void update(ReadView const &base, std::shared_ptr< SLE > const &sle)
bool exists(ReadView const &base, Keylet const &k) const
void visit(ReadView const &base, std::function< void(uint256 const &key, bool isDelete, std::shared_ptr< SLE const > const &before, std::shared_ptr< SLE const > const &after)> const &func) const
static void threadItem(TxMeta &meta, std::shared_ptr< SLE > const &to)
ApplyStateTable & operator=(ApplyStateTable &&)=delete
std::shared_ptr< SLE > getForMod(ReadView const &base, key_type const &key, Mods &mods, beast::Journal j)
void threadOwners(ReadView const &base, TxMeta &meta, std::shared_ptr< SLE const > const &sle, Mods &mods, beast::Journal j)
ApplyStateTable(ApplyStateTable &&)=default
ApplyStateTable & operator=(ApplyStateTable const &)=delete
void apply(RawView &to) const
std::optional< key_type > succ(ReadView const &base, key_type const &key, std::optional< key_type > const &last) const
void replace(ReadView const &base, std::shared_ptr< SLE > const &sle)
ApplyStateTable(ApplyStateTable const &)=delete
void destroyXRP(XRPAmount const &fee)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
Definition View.cpp:3247
A pair of SHAMap key and LedgerEntryType.
Definition Keylet.h:20