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