rippled
Loading...
Searching...
No Matches
RCLValidations.h
1#ifndef XRPL_APP_CONSENSUSS_VALIDATIONS_H_INCLUDED
2#define XRPL_APP_CONSENSUSS_VALIDATIONS_H_INCLUDED
3
4#include <xrpld/app/ledger/Ledger.h>
5#include <xrpld/consensus/Validations.h>
6
7#include <xrpl/protocol/Protocol.h>
8#include <xrpl/protocol/RippleLedgerHash.h>
9#include <xrpl/protocol/STValidation.h>
10
11#include <optional>
12#include <vector>
13
14namespace ripple {
15
16class Application;
17
18enum class BypassAccept : bool { no = false, yes };
19
25{
27
28public:
31
39
42 ledgerID() const
43 {
44 return val_->getLedgerHash();
45 }
46
49 seq() const
50 {
51 return val_->getFieldU32(sfLedgerSequence);
52 }
53
56 signTime() const
57 {
58 return val_->getSignTime();
59 }
60
63 seenTime() const
64 {
65 return val_->getSeenTime();
66 }
67
70 key() const
71 {
72 return val_->getSignerPublic();
73 }
74
76 NodeID
77 nodeID() const
78 {
79 return val_->getNodeID();
80 }
81
83 bool
84 trusted() const
85 {
86 return val_->isTrusted();
87 }
88
89 void
91 {
92 val_->setTrusted();
93 }
94
95 void
97 {
98 val_->setUntrusted();
99 }
100
102 bool
103 full() const
104 {
105 return val_->isFull();
106 }
107
110 loadFee() const
111 {
112 return ~(*val_)[~sfLoadFee];
113 }
114
117 cookie() const
118 {
119 return (*val_)[sfCookie];
120 }
121
124 unwrap() const
125 {
126 return val_;
127 }
128};
129
140{
141public:
142 using ID = LedgerHash;
145 {
146 explicit MakeGenesis() = default;
147 };
148
150
152 std::shared_ptr<Ledger const> const& ledger,
154
156 Seq
157 seq() const;
158
160 ID
161 id() const;
162
169 ID
170 operator[](Seq const& s) const;
171
173 friend Seq
175
176 Seq
177 minSeq() const;
178
179private:
184};
185
192{
193public:
194 // Type definitions for generic Validation
198
200
204 now() const;
205
208 acquire(LedgerHash const& id);
209
211 journal() const
212 {
213 return j_;
214 }
215
216private:
219};
220
223
233void
235 Application& app,
237 std::string const& source,
238 BypassAccept const bypassAccept = BypassAccept::no,
240
241} // namespace ripple
242
243#endif
A generic endpoint for log messages.
Definition Journal.h:41
A public key.
Definition PublicKey.h:43
Wraps a ledger instance for use in generic Validations LedgerTrie.
ID id() const
The ID (hash) of the ledger.
ID operator[](Seq const &s) const
Lookup the ID of the ancestor ledger.
friend Seq mismatch(RCLValidatedLedger const &a, RCLValidatedLedger const &b)
Find the sequence number of the earliest mismatching ancestor.
std::vector< uint256 > ancestors_
Seq seq() const
The sequence (index) of the ledger.
Wrapper over STValidation for generic Validation code.
std::shared_ptr< STValidation > val_
std::optional< std::uint32_t > loadFee() const
Get the load fee of the validation if it exists.
bool trusted() const
Whether the validation is considered trusted.
std::uint32_t seq() const
Validated ledger's sequence number (0 if none)
NetClock::time_point signTime() const
Validation's signing time.
NetClock::time_point seenTime() const
Validated ledger's first seen time.
std::uint64_t cookie() const
Get the cookie specified in the validation (0 if not set)
RCLValidation(std::shared_ptr< STValidation > const &v)
Constructor.
uint256 ledgerID() const
Validated ledger's hash.
std::shared_ptr< STValidation > unwrap() const
Extract the underlying STValidation being wrapped.
NodeID nodeID() const
NodeID of validator that published the validation.
bool full() const
Whether the validation is full (not-partial)
PublicKey key() const
Public key of validator that published the validation.
Generic validations adaptor class for RCL.
beast::Journal journal() const
std::optional< RCLValidatedLedger > acquire(LedgerHash const &id)
Attempt to acquire the ledger with given id from the network.
NetClock::time_point now() const
Current time used to determine if validations are stale.
T is_same_v
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
std::uint32_t LedgerIndex
A ledger index.
Definition Protocol.h:120
base_uint< 160, detail::NodeIDTag > NodeID
NodeID is a 160-bit hash representing one node.
Definition UintTypes.h:40
void handleNewValidation(Application &app, std::shared_ptr< STValidation > const &val, std::string const &source, BypassAccept const bypassAccept, std::optional< beast::Journal > j)
Handle a new validation.
@ no
Definition Steps.h:26
@ yes
Definition Steps.h:26
uint256 LedgerHash