xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
include
xrpl
ledger
entries
AmendmentsEntry.h
1
#pragma once
2
3
#include <xrpl/basics/base_uint.h>
4
#include <xrpl/basics/chrono.h>
5
#include <xrpl/beast/utility/Journal.h>
6
#include <xrpl/ledger/ApplyView.h>
7
#include <xrpl/ledger/ReadView.h>
8
#include <xrpl/ledger/entries/SLEBase.h>
9
#include <xrpl/protocol/Indexes.h>
10
#include <xrpl/protocol/LedgerFormats.h>
11
#include <xrpl/protocol/SField.h>
12
13
#include <
map
>
14
#include <
set
>
15
16
namespace
xrpl
{
17
18
template
<
typename
ViewT>
19
class
AmendmentsEntry
:
public
SLEBase
<ViewT, ltAMENDMENTS>
20
{
21
public
:
22
using
Base
=
SLEBase<ViewT, ltAMENDMENTS>
;
23
24
// Inherit base constructors: adopt an existing SLE, or resolve one from a
25
// Keylet against the view.
26
using
Base::Base;
27
28
explicit
AmendmentsEntry
(
29
Base::ViewRefType
view,
30
beast::Journal
j =
beast::Journal
{
beast::Journal::getNullSink
()})
31
: Base(
keylet
::amendments(), view, j)
32
{
33
}
34
40
[[nodiscard]]
std::set<UInt256>
41
enabledAmendments
()
const
42
{
43
std::set<UInt256>
amendments;
44
45
if
(this->
exists
() && (*this)->isFieldPresent(sfAmendments))
46
{
47
auto
const
& v = (*this)->getFieldV256(sfAmendments);
48
amendments.insert_range(v);
49
}
50
51
return
amendments;
52
}
53
60
[[nodiscard]]
std::map<UInt256, NetClock::time_point>
61
majorityAmendments
()
const
62
{
63
std::map<UInt256, NetClock::time_point>
ret;
64
65
if
(this->
exists
() && (*this)->isFieldPresent(sfMajorities))
66
{
67
using
TimePoint =
NetClock::time_point
;
68
using
Duration = TimePoint::duration;
69
70
auto
const
majorities = (*this)->getFieldArray(sfMajorities);
71
72
for
(
auto
const
& m : majorities)
73
{
74
ret[m.getFieldH256(sfAmendment)] = TimePoint(Duration(m.getFieldU32(sfCloseTime)));
75
}
76
}
77
78
return
ret;
79
}
80
};
81
82
using
AmendmentsEntryR
=
AmendmentsEntry<ReadView>
;
83
using
AmendmentsEntryW
=
AmendmentsEntry<ApplyView>
;
84
85
}
// namespace xrpl
beast::Journal
A generic endpoint for log messages.
Definition
Journal.h:44
beast::Journal::getNullSink
static Sink & getNullSink()
Returns a Sink which does nothing.
Definition
beast_Journal.cpp:63
xrpl::AmendmentsEntry
Definition
AmendmentsEntry.h:20
xrpl::AmendmentsEntry::Base
SLEBase< ViewT, ltAMENDMENTS > Base
Definition
AmendmentsEntry.h:22
xrpl::AmendmentsEntry::enabledAmendments
std::set< UInt256 > enabledAmendments() const
Returns the set of amendments this entry reports as enabled.
Definition
AmendmentsEntry.h:41
xrpl::AmendmentsEntry::AmendmentsEntry
AmendmentsEntry(Base::ViewRefType view, beast::Journal j=beast::Journal{beast::Journal::getNullSink()})
Definition
AmendmentsEntry.h:28
xrpl::AmendmentsEntry::majorityAmendments
std::map< UInt256, NetClock::time_point > majorityAmendments() const
Returns a map of amendments that have achieved majority, to the time majority was reached.
Definition
AmendmentsEntry.h:61
xrpl::NetClock::time_point
std::chrono::time_point< NetClock > time_point
Definition
chrono.h:48
xrpl::SLEBase< ViewT, ltAMENDMENTS >::exists
bool exists() const
Definition
SLEBase.h:227
xrpl::SLEBase::ViewRefType
std::conditional_t< kIsWritable, ApplyView &, ReadView const & > ViewRefType
Definition
SLEBase.h:106
xrpl::SLEBase< ViewT, ltAMENDMENTS >::SLEBase
SLEBase(SLEBase const &)=default
map
xrpl::keylet
Keylet computation functions.
Definition
Indexes.h:40
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::AmendmentsEntryR
AmendmentsEntry< ReadView > AmendmentsEntryR
Definition
AmendmentsEntry.h:82
xrpl::AmendmentsEntryW
AmendmentsEntry< ApplyView > AmendmentsEntryW
Definition
AmendmentsEntry.h:83
set
Generated by
1.17.0