rippled
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
11#include <memory>
12
13namespace xrpl {
14namespace detail {
15
16// Helper class that buffers modifications
18{
19public:
21
22private:
23 enum class Action {
24 cache,
25 erase,
26 insert,
27 modify,
28 };
29
31
34
35public:
36 ApplyStateTable() = default;
38
43 operator=(ApplyStateTable const&) = delete;
44
45 void
46 apply(RawView& to) const;
47
49 apply(
50 OpenView& to,
51 STTx const& tx,
52 TER ter,
53 std::optional<STAmount> const& deliver,
54 std::optional<uint256 const> const& parentBatchId,
55 bool isDryRun,
57
58 bool
59 exists(ReadView const& base, Keylet const& k) const;
60
62 succ(ReadView const& base, key_type const& key, std::optional<key_type> const& last) const;
63
65 read(ReadView const& base, Keylet const& k) const;
66
68 peek(ReadView const& base, Keylet const& k);
69
71 size() const;
72
73 void
74 visit(
75 ReadView const& base,
76 std::function<void(
77 uint256 const& key,
78 bool isDelete,
79 std::shared_ptr<SLE const> const& before,
80 std::shared_ptr<SLE const> const& after)> const& func) const;
81
82 void
83 erase(ReadView const& base, std::shared_ptr<SLE> const& sle);
84
85 void
86 rawErase(ReadView const& base, std::shared_ptr<SLE> const& sle);
87
88 void
89 insert(ReadView const& base, std::shared_ptr<SLE> const& sle);
90
91 void
92 update(ReadView const& base, std::shared_ptr<SLE> const& sle);
93
94 void
95 replace(ReadView const& base, std::shared_ptr<SLE> const& sle);
96
97 void
98 destroyXRP(XRPAmount const& fee);
99
100 // For debugging
101 XRPAmount const&
103 {
104 return dropsDestroyed_;
105 }
106
107private:
109
110 static void
111 threadItem(TxMeta& meta, std::shared_ptr<SLE> const& to);
112
114 getForMod(ReadView const& base, key_type const& key, Mods& mods, beast::Journal j);
115
116 void
117 threadTx(ReadView const& base, TxMeta& meta, AccountID const& to, Mods& mods, beast::Journal j);
118
119 void
121 ReadView const& base,
122 TxMeta& meta,
124 Mods& mods,
126};
127
128} // namespace detail
129} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:40
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
void destroyXRP(XRPAmount const &fee)
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
XRPAmount const & dropsDestroyed() const
std::shared_ptr< SLE > peek(ReadView const &base, Keylet const &k)
void replace(ReadView const &base, std::shared_ptr< SLE > const &sle)
static void threadItem(TxMeta &meta, std::shared_ptr< SLE > const &to)
std::optional< key_type > succ(ReadView const &base, key_type const &key, std::optional< key_type > const &last) const
void rawErase(ReadView const &base, std::shared_ptr< SLE > const &sle)
void threadTx(ReadView const &base, TxMeta &meta, AccountID const &to, Mods &mods, beast::Journal j)
ApplyStateTable & operator=(ApplyStateTable const &)=delete
void threadOwners(ReadView const &base, TxMeta &meta, std::shared_ptr< SLE const > const &sle, Mods &mods, beast::Journal j)
std::shared_ptr< SLE > getForMod(ReadView const &base, key_type const &key, Mods &mods, beast::Journal j)
std::shared_ptr< SLE const > read(ReadView const &base, Keylet const &k) const
void apply(RawView &to) const
ApplyStateTable & operator=(ApplyStateTable &&)=delete
void update(ReadView const &base, std::shared_ptr< SLE > const &sle)
ApplyStateTable(ApplyStateTable const &)=delete
ApplyStateTable(ApplyStateTable &&)=default
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
Definition View.cpp:3436
A pair of SHAMap key and LedgerEntryType.
Definition Keylet.h:19