rippled
Loading...
Searching...
No Matches
Validation.h
1#ifndef XRPL_TEST_CSF_VALIDATION_H_INCLUDED
2#define XRPL_TEST_CSF_VALIDATION_H_INCLUDED
3
4#include <test/csf/ledgers.h>
5
6#include <xrpl/basics/tagged_integer.h>
7
8#include <memory>
9#include <optional>
10#include <utility>
11
12namespace ripple {
13namespace test {
14namespace csf {
15
16struct PeerIDTag;
17//< Uniquely identifies a peer
19
27
31{
34
39 bool trusted_ = false;
40 bool full_ = false;
43
44public:
46 using NodeID = PeerID;
47
69
71 ledgerID() const
72 {
73 return ledgerID_;
74 }
75
77 seq() const
78 {
79 return seq_;
80 }
81
83 signTime() const
84 {
85 return signTime_;
86 }
87
89 seenTime() const
90 {
91 return seenTime_;
92 }
93
94 PeerKey const&
95 key() const
96 {
97 return key_;
98 }
99
100 PeerID const&
101 nodeID() const
102 {
103 return nodeID_;
104 }
105
106 bool
107 trusted() const
108 {
109 return trusted_;
110 }
111
112 bool
113 full() const
114 {
115 return full_;
116 }
117
119 cookie() const
120 {
121 return cookie_;
122 }
123
125 loadFee() const
126 {
127 return loadFee_;
128 }
129
130 Validation const&
131 unwrap() const
132 {
133 // For the rippled implementation in which RCLValidation wraps
134 // STValidation, the csf::Validation has no more specific type it
135 // wraps, so csf::Validation unwraps to itself
136 return *this;
137 }
138
139 auto
140 asTie() const
141 {
142 // trusted is a status set by the receiver, so it is not part of the tie
143 return std::tie(
144 ledgerID_,
145 seq_,
146 signTime_,
147 seenTime_,
148 key_,
149 nodeID_,
150 loadFee_,
151 full_);
152 }
153 bool
154 operator==(Validation const& o) const
155 {
156 return asTie() == o.asTie();
157 }
158
159 bool
160 operator<(Validation const& o) const
161 {
162 return asTie() < o.asTie();
163 }
164
165 void
167 {
168 trusted_ = true;
169 }
170
171 void
173 {
174 trusted_ = false;
175 }
176
177 void
179 {
180 seenTime_ = seen;
181 }
182};
183
184} // namespace csf
185} // namespace test
186} // namespace ripple
187
188#endif
Validation of a specific ledger by a specific Peer.
Definition Validation.h:31
NetClock::time_point seenTime() const
Definition Validation.h:89
Ledger::Seq seq() const
Definition Validation.h:77
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:48
std::optional< std::uint32_t > loadFee_
Definition Validation.h:41
Validation const & unwrap() const
Definition Validation.h:131
PeerKey const & key() const
Definition Validation.h:95
Ledger::ID ledgerID() const
Definition Validation.h:71
void setSeen(NetClock::time_point seen)
Definition Validation.h:178
PeerID const & nodeID() const
Definition Validation.h:101
NetClock::time_point signTime_
Definition Validation.h:35
bool operator<(Validation const &o) const
Definition Validation.h:160
NetClock::time_point seenTime_
Definition Validation.h:36
bool operator==(Validation const &o) const
Definition Validation.h:154
NetClock::time_point signTime() const
Definition Validation.h:83
std::optional< std::uint32_t > loadFee() const
Definition Validation.h:125
std::uint64_t cookie() const
Definition Validation.h:119
T is_same_v
std::pair< PeerID, std::uint32_t > PeerKey
The current key of a peer.
Definition Validation.h:26
tagged_integer< std::uint32_t, PeerIDTag > PeerID
Definition Validation.h:18
void sign(Json::Value &jv, Account const &account, Json::Value &sigObject)
Sign automatically into a specific Json field of the jv object.
Definition utility.cpp:28
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
Set the sequence number on a JTx.
Definition seq.h:15
T tie(T... args)