rippled
Loading...
Searching...
No Matches
RCLValidations.h
1#pragma once
2
3#include <xrpld/app/ledger/Ledger.h>
4#include <xrpld/consensus/Validations.h>
5
6#include <xrpl/protocol/Protocol.h>
7#include <xrpl/protocol/RippleLedgerHash.h>
8#include <xrpl/protocol/STValidation.h>
9
10#include <optional>
11#include <vector>
12
13namespace xrpl {
14
15class Application;
16
17enum class BypassAccept : bool { no = false, yes };
18
24{
26
27public:
30
38
41 ledgerID() const
42 {
43 return val_->getLedgerHash();
44 }
45
48 seq() const
49 {
50 return val_->getFieldU32(sfLedgerSequence);
51 }
52
55 signTime() const
56 {
57 return val_->getSignTime();
58 }
59
62 seenTime() const
63 {
64 return val_->getSeenTime();
65 }
66
69 key() const
70 {
71 return val_->getSignerPublic();
72 }
73
75 NodeID
76 nodeID() const
77 {
78 return val_->getNodeID();
79 }
80
82 bool
83 trusted() const
84 {
85 return val_->isTrusted();
86 }
87
88 void
90 {
91 val_->setTrusted();
92 }
93
94 void
96 {
97 val_->setUntrusted();
98 }
99
101 bool
102 full() const
103 {
104 return val_->isFull();
105 }
106
109 loadFee() const
110 {
111 return ~(*val_)[~sfLoadFee];
112 }
113
116 cookie() const
117 {
118 return (*val_)[sfCookie];
119 }
120
123 unwrap() const
124 {
125 return val_;
126 }
127};
128
139{
140public:
141 using ID = LedgerHash;
144 {
145 explicit MakeGenesis() = default;
146 };
147
149
151
153 Seq
154 seq() const;
155
157 ID
158 id() const;
159
166 ID
167 operator[](Seq const& s) const;
168
170 friend Seq
172
173 Seq
174 minSeq() const;
175
176private:
181};
182
189{
190public:
191 // Type definitions for generic Validation
195
197
201 now() const;
202
205 acquire(LedgerHash const& id);
206
208 journal() const
209 {
210 return j_;
211 }
212
213private:
216};
217
220
230void
232 Application& app,
234 std::string const& source,
235 BypassAccept const bypassAccept = BypassAccept::no,
237
238} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:40
A public key.
Definition PublicKey.h:42
Wraps a ledger instance for use in generic Validations LedgerTrie.
friend Seq mismatch(RCLValidatedLedger const &a, RCLValidatedLedger const &b)
Find the sequence number of the earliest mismatching ancestor.
Seq seq() const
The sequence (index) of the ledger.
ID id() const
The ID (hash) of the ledger.
ID operator[](Seq const &s) const
Lookup the ID of the ancestor ledger.
std::vector< uint256 > ancestors_
Wrapper over STValidation for generic Validation code.
std::uint32_t seq() const
Validated ledger's sequence number (0 if none)
bool full() const
Whether the validation is full (not-partial)
RCLValidation(std::shared_ptr< STValidation > const &v)
Constructor.
NodeID nodeID() const
NodeID of validator that published the validation.
std::shared_ptr< STValidation > val_
bool trusted() const
Whether the validation is considered trusted.
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)
std::optional< std::uint32_t > loadFee() const
Get the load fee of the validation if it exists.
NetClock::time_point signTime() const
Validation's signing time.
PublicKey key() const
Public key of validator that published the validation.
std::shared_ptr< STValidation > unwrap() const
Extract the underlying STValidation being wrapped.
uint256 ledgerID() const
Validated ledger's hash.
Generic validations adaptor class for RCL.
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.
beast::Journal journal() const
T is_same_v
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
base_uint< 160, detail::NodeIDTag > NodeID
NodeID is a 160-bit hash representing one node.
Definition UintTypes.h:39
uint256 LedgerHash
std::uint32_t LedgerIndex
A ledger index.
Definition Protocol.h:254
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:25
@ yes
Definition Steps.h:25