xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
tests
libxrpl
csf
Validation.h
1
#pragma once
2
3
#include <xrpl/basics/chrono.h>
4
#include <xrpl/basics/tagged_integer.h>
5
6
#include <csf/ledgers.h>
7
8
#include <
cstdint
>
9
#include <
optional
>
10
#include <
tuple
>
11
#include <
utility
>
12
13
namespace
xrpl::test::csf
{
14
15
struct
PeerIDTag;
16
//< Uniquely identifies a peer
17
using
PeerID
=
TaggedInteger<std::uint32_t, PeerIDTag>
;
18
26
using
PeerKey
=
std::pair<PeerID, std::uint32_t>
;
27
31
class
Validation
32
{
33
Ledger::ID
ledgerID_
{0};
34
Ledger::Seq
seq_
{0};
35
36
NetClock::time_point
signTime_
;
37
NetClock::time_point
seenTime_
;
38
PeerKey
key_
;
39
PeerID
nodeID_
{0};
40
bool
trusted_
=
false
;
41
bool
full_
=
false
;
42
std::optional<std::uint32_t>
loadFee_
;
43
std::uint64_t
cookie_
{0};
44
45
public
:
46
using
NodeKey
=
PeerKey
;
47
using
NodeID
=
PeerID
;
48
49
Validation
(
50
Ledger::ID
id
,
51
Ledger::Seq
seq
,
52
NetClock::time_point
sign
,
53
NetClock::time_point
seen,
54
PeerKey
key
,
55
PeerID
nodeID
,
56
bool
full
,
57
std::optional<std::uint32_t>
loadFee
= std::nullopt,
58
std::uint64_t
cookie
= 0)
59
:
ledgerID_
{id}
60
,
seq_
{
seq
}
61
,
signTime_
{
sign
}
62
,
seenTime_
{seen}
63
,
key_
{
std
::move(
key
)}
64
,
nodeID_
{
nodeID
}
65
,
full_
{
full
}
66
,
loadFee_
{
loadFee
}
67
,
cookie_
{
cookie
}
68
{
69
}
70
71
[[nodiscard]]
Ledger::ID
72
ledgerID
()
const
73
{
74
return
ledgerID_
;
75
}
76
77
[[nodiscard]]
Ledger::Seq
78
seq
()
const
79
{
80
return
seq_
;
81
}
82
83
[[nodiscard]]
NetClock::time_point
84
signTime
()
const
85
{
86
return
signTime_
;
87
}
88
89
[[nodiscard]]
NetClock::time_point
90
seenTime
()
const
91
{
92
return
seenTime_
;
93
}
94
95
[[nodiscard]]
PeerKey
const
&
96
key
()
const
97
{
98
return
key_
;
99
}
100
101
[[nodiscard]]
PeerID
const
&
102
nodeID
()
const
103
{
104
return
nodeID_
;
105
}
106
107
[[nodiscard]]
bool
108
trusted
()
const
109
{
110
return
trusted_
;
111
}
112
113
[[nodiscard]]
bool
114
full
()
const
115
{
116
return
full_
;
117
}
118
119
[[nodiscard]]
std::uint64_t
120
cookie
()
const
121
{
122
return
cookie_
;
123
}
124
125
[[nodiscard]]
std::optional<std::uint32_t>
126
loadFee
()
const
127
{
128
return
loadFee_
;
129
}
130
131
[[nodiscard]]
Validation
const
&
132
unwrap
()
const
133
{
134
// For the xrpld implementation in which RCLValidation wraps
135
// STValidation, the csf::Validation has no more specific type it
136
// wraps, so csf::Validation unwraps to itself
137
return
*
this
;
138
}
139
140
[[nodiscard]]
auto
141
asTie
()
const
142
{
143
// trusted is a status set by the receiver, so it is not part of the tie
144
return
std::tie
(
ledgerID_
,
seq_
,
signTime_
,
seenTime_
,
key_
,
nodeID_
,
loadFee_
,
full_
);
145
}
146
bool
147
operator==
(
Validation
const
& o)
const
148
{
149
return
asTie
() == o.
asTie
();
150
}
151
152
bool
153
operator<
(
Validation
const
& o)
const
154
{
155
return
asTie
() < o.
asTie
();
156
}
157
158
void
159
setTrusted
()
160
{
161
trusted_
=
true
;
162
}
163
164
void
165
setUntrusted
()
166
{
167
trusted_
=
false
;
168
}
169
170
void
171
setSeen
(
NetClock::time_point
seen)
172
{
173
seenTime_
= seen;
174
}
175
};
176
177
}
// namespace xrpl::test::csf
xrpl::NetClock::time_point
std::chrono::time_point< NetClock > time_point
Definition
chrono.h:48
xrpl::TaggedInteger
A type-safe wrap around standard integral types.
Definition
tagged_integer.h:37
xrpl::test::csf::Ledger::ID
TaggedInteger< std::uint32_t, IdTag > ID
Definition
ledgers.h:56
xrpl::test::csf::Ledger::Seq
TaggedInteger< std::uint32_t, SeqTag > Seq
Definition
ledgers.h:53
xrpl::test::csf::Validation
Validation of a specific ledger by a specific Peer.
Definition
Validation.h:32
xrpl::test::csf::Validation::asTie
auto asTie() const
Definition
Validation.h:141
xrpl::test::csf::Validation::trusted
bool trusted() const
Definition
Validation.h:108
xrpl::test::csf::Validation::seq_
Ledger::Seq seq_
Definition
Validation.h:34
xrpl::test::csf::Validation::cookie_
std::uint64_t cookie_
Definition
Validation.h:43
xrpl::test::csf::Validation::loadFee
std::optional< std::uint32_t > loadFee() const
Definition
Validation.h:126
xrpl::test::csf::Validation::loadFee_
std::optional< std::uint32_t > loadFee_
Definition
Validation.h:42
xrpl::test::csf::Validation::seenTime
NetClock::time_point seenTime() const
Definition
Validation.h:90
xrpl::test::csf::Validation::key_
PeerKey key_
Definition
Validation.h:38
xrpl::test::csf::Validation::operator==
bool operator==(Validation const &o) const
Definition
Validation.h:147
xrpl::test::csf::Validation::setSeen
void setSeen(NetClock::time_point seen)
Definition
Validation.h:171
xrpl::test::csf::Validation::signTime_
NetClock::time_point signTime_
Definition
Validation.h:36
xrpl::test::csf::Validation::key
PeerKey const & key() const
Definition
Validation.h:96
xrpl::test::csf::Validation::cookie
std::uint64_t cookie() const
Definition
Validation.h:120
xrpl::test::csf::Validation::NodeID
PeerID NodeID
Definition
Validation.h:47
xrpl::test::csf::Validation::signTime
NetClock::time_point signTime() const
Definition
Validation.h:84
xrpl::test::csf::Validation::nodeID
PeerID const & nodeID() const
Definition
Validation.h:102
xrpl::test::csf::Validation::seenTime_
NetClock::time_point seenTime_
Definition
Validation.h:37
xrpl::test::csf::Validation::full
bool full() const
Definition
Validation.h:114
xrpl::test::csf::Validation::Validation
Validation(Ledger::ID id, Ledger::Seq seq, NetClock::time_point sign, NetClock::time_point seen, PeerKey key, PeerID nodeID, bool full, std::optional< std::uint32_t > loadFee=std::nullopt, std::uint64_t cookie=0)
Definition
Validation.h:49
xrpl::test::csf::Validation::trusted_
bool trusted_
Definition
Validation.h:40
xrpl::test::csf::Validation::nodeID_
PeerID nodeID_
Definition
Validation.h:39
xrpl::test::csf::Validation::NodeKey
PeerKey NodeKey
Definition
Validation.h:46
xrpl::test::csf::Validation::ledgerID_
Ledger::ID ledgerID_
Definition
Validation.h:33
xrpl::test::csf::Validation::operator<
bool operator<(Validation const &o) const
Definition
Validation.h:153
xrpl::test::csf::Validation::full_
bool full_
Definition
Validation.h:41
xrpl::test::csf::Validation::seq
Ledger::Seq seq() const
Definition
Validation.h:78
xrpl::test::csf::Validation::ledgerID
Ledger::ID ledgerID() const
Definition
Validation.h:72
xrpl::test::csf::Validation::unwrap
Validation const & unwrap() const
Definition
Validation.h:132
xrpl::test::csf::Validation::setTrusted
void setTrusted()
Definition
Validation.h:159
xrpl::test::csf::Validation::setUntrusted
void setUntrusted()
Definition
Validation.h:165
cstdint
std::uint64_t
std
STL namespace.
xrpl::test::csf
Definition
Validations.cpp:23
xrpl::test::csf::PeerID
TaggedInteger< std::uint32_t, PeerIDTag > PeerID
Definition
Validation.h:17
xrpl::test::csf::PeerKey
std::pair< PeerID, std::uint32_t > PeerKey
The current key of a peer.
Definition
Validation.h:26
xrpl::test::jtx::sign
void sign(json::Value &jv, Account const &account, json::Value &sigObject, HashPrefix prefix)
Sign automatically into a specific Json field of the jv object.
Definition
utility.cpp:52
optional
std::pair
std::tie
T tie(T... args)
tuple
utility
Generated by
1.17.0