rippled
Loading...
Searching...
No Matches
RawStateTable.h
1#ifndef XRPL_LEDGER_RAWSTATETABLE_H_INCLUDED
2#define XRPL_LEDGER_RAWSTATETABLE_H_INCLUDED
3
4#include <xrpl/ledger/RawView.h>
5#include <xrpl/ledger/ReadView.h>
6
7#include <boost/container/pmr/monotonic_buffer_resource.hpp>
8#include <boost/container/pmr/polymorphic_allocator.hpp>
9
10#include <map>
11#include <utility>
12
13namespace ripple {
14namespace detail {
15
16// Helper class that buffers raw modifications
18{
19public:
21 // Initial size for the monotonic_buffer_resource used for allocations
22 // The size was chosen from the old `qalloc` code (which this replaces).
23 // It is unclear how the size initially chosen in qalloc.
24 static constexpr size_t initialBufferSize = kilobytes(256);
25
27 : monotonic_resource_{std::make_unique<
28 boost::container::pmr::monotonic_buffer_resource>(
31
33 : monotonic_resource_{std::make_unique<
34 boost::container::pmr::monotonic_buffer_resource>(
38
40
44 operator=(RawStateTable const&) = delete;
45
46 void
47 apply(RawView& to) const;
48
49 bool
50 exists(ReadView const& base, Keylet const& k) const;
51
53 succ(
54 ReadView const& base,
55 key_type const& key,
56 std::optional<key_type> const& last) const;
57
58 void
59 erase(std::shared_ptr<SLE> const& sle);
60
61 void
62 insert(std::shared_ptr<SLE> const& sle);
63
64 void
65 replace(std::shared_ptr<SLE> const& sle);
66
68 read(ReadView const& base, Keylet const& k) const;
69
70 void
71 destroyXRP(XRPAmount const& fee);
72
74 slesBegin(ReadView const& base) const;
75
77 slesEnd(ReadView const& base) const;
78
80 slesUpperBound(ReadView const& base, uint256 const& key) const;
81
82private:
83 enum class Action {
84 erase,
85 insert,
86 replace,
87 };
88
89 class sles_iter_impl;
90
91 struct sleAction
92 {
95
96 // Constructor needed for emplacement in std::map
98 : action(action_), sle(sle_)
99 {
100 }
101 };
102
103 // Use boost::pmr functionality instead of the std::pmr
104 // functions b/c clang does not support pmr yet (as-of 9/2020)
106 key_type,
107 sleAction,
109 boost::container::pmr::polymorphic_allocator<
111 // monotonic_resource_ must outlive `items_`. Make a pointer so it may be
112 // easily moved.
116
118};
119
120} // namespace detail
121} // namespace ripple
122
123#endif
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::optional< key_type > succ(ReadView const &base, key_type const &key, std::optional< key_type > const &last) const
void destroyXRP(XRPAmount const &fee)
RawStateTable(RawStateTable const &rhs)
bool exists(ReadView const &base, Keylet const &k) const
void apply(RawView &to) const
std::unique_ptr< ReadView::sles_type::iter_base > slesUpperBound(ReadView const &base, uint256 const &key) const
ReadView::key_type key_type
RawStateTable & operator=(RawStateTable const &)=delete
std::shared_ptr< SLE const > read(ReadView const &base, Keylet const &k) const
std::unique_ptr< ReadView::sles_type::iter_base > slesBegin(ReadView const &base) const
RawStateTable & operator=(RawStateTable &&)=delete
std::unique_ptr< ReadView::sles_type::iter_base > slesEnd(ReadView const &base) const
std::unique_ptr< boost::container::pmr::monotonic_buffer_resource > monotonic_resource_
static constexpr size_t initialBufferSize
RawStateTable(RawStateTable &&)=default
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
constexpr auto kilobytes(T value) noexcept
T get(Section const &section, std::string const &name, T const &defaultValue=T{})
Retrieve a key/value pair from a section.
STL namespace.
A pair of SHAMap key and LedgerEntryType.
Definition Keylet.h:20
sleAction(Action action_, std::shared_ptr< SLE > const &sle_)