xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
libxrpl
ledger
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/ledger/entries/AmendmentsEntry.h>
7
#include <xrpl/protocol/Indexes.h>
8
#include <xrpl/protocol/Keylet.h>
9
#include <xrpl/protocol/Rules.h>
10
#include <xrpl/protocol/SField.h>
11
12
#include <
optional
>
13
#include <
unordered_set
>
14
15
namespace
xrpl
{
16
17
ReadView::SlesType::SlesType
(
ReadView
const
& view) :
ReadViewFwdRange
(view)
18
{
19
}
20
21
auto
22
ReadView::SlesType::begin
() const -> Iterator
23
{
24
return
Iterator(
view_
,
view_
->slesBegin());
25
}
26
27
auto
28
ReadView::SlesType::end
() const -> Iterator
29
{
30
return
Iterator(
view_
,
view_
->slesEnd());
31
}
32
33
auto
34
ReadView::SlesType::upperBound
(
key_type
const
& key)
const
-> Iterator
35
{
36
return
Iterator(
view_
,
view_
->slesUpperBound(key));
37
}
38
39
ReadView::TxsType::TxsType
(
ReadView
const
& view) :
ReadViewFwdRange
(view)
40
{
41
}
42
43
bool
44
ReadView::TxsType::empty
()
const
45
{
46
return
begin
() ==
end
();
47
}
48
49
auto
50
ReadView::TxsType::begin
() const -> Iterator
51
{
52
return
Iterator(
view_
,
view_
->txsBegin());
53
}
54
55
auto
56
ReadView::TxsType::end
() const -> Iterator
57
{
58
return
Iterator(
view_
,
view_
->txsEnd());
59
}
60
61
Rules
62
makeRulesGivenLedger
(
DigestAwareReadView
const
& ledger,
Rules
const
& current)
63
{
64
return
makeRulesGivenLedger
(ledger, current.
presets
());
65
}
66
67
Rules
68
makeRulesGivenLedger
(
69
DigestAwareReadView
const
& ledger,
70
std::unordered_set
<
UInt256
,
beast::Uhash<>
>
const
&
presets
)
71
{
72
Keylet
const
k =
keylet::amendments
();
73
std::optional
const
digest
= ledger.
digest
(k.
key
);
74
if
(
digest
)
75
{
76
if
(
AmendmentsEntryR
const
entry(k, ledger); entry)
77
return
Rules
(
presets
,
digest
, entry->getFieldV256(sfAmendments));
78
}
79
return
Rules
(
presets
);
80
}
81
82
}
// namespace xrpl
xrpl::DigestAwareReadView
ReadView that associates keys with digests.
Definition
ReadView.h:279
xrpl::DigestAwareReadView::digest
virtual std::optional< DigestType > digest(key_type const &key) const =0
Return the digest associated with the key.
xrpl::ReadView::ReadView
ReadView()
Definition
ReadView.h:78
xrpl::ReadView::key_type
UInt256 key_type
Definition
ReadView.h:45
xrpl::Rules
Rules controlling protocol behavior.
Definition
Rules.h:40
xrpl::Rules::Rules
Rules(Rules const &)=default
xrpl::Rules::presets
std::unordered_set< UInt256, beast::Uhash<> > const & presets() const
Definition
Rules.cpp:176
xrpl::detail::ReadViewFwdRange< SLE::const_pointer >::view_
ReadView const * view_
Definition
ReadViewFwdRange.h:125
xrpl::detail::ReadViewFwdRange< SLE::const_pointer >::ReadViewFwdRange
ReadViewFwdRange()=delete
xrpl::keylet::amendments
Keylet const & amendments() noexcept
The index of the amendment table.
Definition
Indexes.cpp:248
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::digest
static Hasher::result_type digest(void const *data, std::size_t size) noexcept
Definition
tokens.cpp:140
xrpl::makeRulesGivenLedger
Rules makeRulesGivenLedger(DigestAwareReadView const &ledger, Rules const ¤t)
Definition
ReadView.cpp:62
xrpl::UInt256
BaseUInt< 256 > UInt256
Definition
base_uint.h:580
xrpl::AmendmentsEntryR
AmendmentsEntry< ReadView > AmendmentsEntryR
Definition
AmendmentsEntry.h:82
optional
beast::Uhash
Definition
uhash.h:11
xrpl::Keylet
A pair of SHAMap key and LedgerEntryType.
Definition
Keylet.h:20
xrpl::Keylet::key
UInt256 key
Definition
Keylet.h:21
xrpl::ReadView::SlesType::begin
Iterator begin() const
Definition
ReadView.cpp:22
xrpl::ReadView::SlesType::upperBound
Iterator upperBound(key_type const &key) const
Definition
ReadView.cpp:34
xrpl::ReadView::SlesType::end
Iterator end() const
Definition
ReadView.cpp:28
xrpl::ReadView::SlesType::SlesType
SlesType(ReadView const &view)
Definition
ReadView.cpp:17
xrpl::ReadView::TxsType::empty
bool empty() const
Definition
ReadView.cpp:44
xrpl::ReadView::TxsType::end
Iterator end() const
Definition
ReadView.cpp:56
xrpl::ReadView::TxsType::begin
Iterator begin() const
Definition
ReadView.cpp:50
xrpl::ReadView::TxsType::TxsType
TxsType(ReadView const &view)
Definition
ReadView.cpp:39
unordered_set
Generated by
1.17.0