xrpld
Loading...
Searching...
No Matches
ReadView.cpp
1#include <xrpl/ledger/ReadView.h>
2
3#include <xrpl/basics/base_uint.h>
4#include <xrpl/beast/hash/uhash.h>
5#include <xrpl/ledger/detail/ReadViewFwdRange.h>
6#include <xrpl/protocol/Indexes.h>
7#include <xrpl/protocol/Keylet.h>
8#include <xrpl/protocol/Rules.h>
9#include <xrpl/protocol/SField.h>
10
11#include <optional>
12#include <unordered_set>
13
14namespace xrpl {
15
19
20auto
21ReadView::SlesType::begin() const -> Iterator
22{
23 return Iterator(view_, view_->slesBegin());
24}
25
26auto
27ReadView::SlesType::end() const -> Iterator
28{
29 return Iterator(view_, view_->slesEnd());
30}
31
32auto
33ReadView::SlesType::upperBound(key_type const& key) const -> Iterator
34{
35 return Iterator(view_, view_->slesUpperBound(key));
36}
37
41
42bool
44{
45 return begin() == end();
46}
47
48auto
49ReadView::TxsType::begin() const -> Iterator
50{
51 return Iterator(view_, view_->txsBegin());
52}
53
54auto
55ReadView::TxsType::end() const -> Iterator
56{
57 return Iterator(view_, view_->txsEnd());
58}
59
61makeRulesGivenLedger(DigestAwareReadView const& ledger, Rules const& current)
62{
63 return makeRulesGivenLedger(ledger, current.presets());
64}
65
68 DigestAwareReadView const& ledger,
70{
71 Keylet const k = keylet::amendments();
72 std::optional const digest = ledger.digest(k.key);
73 if (digest)
74 {
75 auto const sle = ledger.read(k);
76 if (sle)
77 return Rules(presets, digest, sle->getFieldV256(sfAmendments));
78 }
79 return Rules(presets);
80}
81
82} // namespace xrpl
ReadView that associates keys with digests.
Definition ReadView.h:249
virtual std::optional< digest_type > digest(key_type const &key) const =0
Return the digest associated with the key.
virtual SLE::const_pointer read(Keylet const &k) const =0
Return the state item associated with a key.
uint256 key_type
Definition ReadView.h:35
Rules controlling protocol behavior.
Definition Rules.h:33
std::unordered_set< uint256, beast::Uhash<> > const & presets() const
Definition Rules.cpp:165
Rules(Rules const &)=default
friend Rules makeRulesGivenLedger(DigestAwareReadView const &ledger, std::unordered_set< uint256, beast::Uhash<> > const &presets)
Definition ReadView.cpp:67
Keylet const & amendments() noexcept
The index of the amendment table.
Definition Indexes.cpp:214
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
static Hasher::result_type digest(void const *data, std::size_t size) noexcept
Definition tokens.cpp:139
Rules makeRulesGivenLedger(DigestAwareReadView const &ledger, Rules const &current)
Definition ReadView.cpp:61
BaseUInt< 256 > uint256
Definition base_uint.h:562
A pair of SHAMap key and LedgerEntryType.
Definition Keylet.h:19
uint256 key
Definition Keylet.h:20
Iterator begin() const
Definition ReadView.cpp:21
Iterator upperBound(key_type const &key) const
Definition ReadView.cpp:33
Iterator end() const
Definition ReadView.cpp:27
SlesType(ReadView const &view)
Definition ReadView.cpp:16
Iterator end() const
Definition ReadView.cpp:55
Iterator begin() const
Definition ReadView.cpp:49
TxsType(ReadView const &view)
Definition ReadView.cpp:38