rippled
Loading...
Searching...
No Matches
RCLValidations.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_APP_CONSENSUSS_VALIDATIONS_H_INCLUDED
21#define RIPPLE_APP_CONSENSUSS_VALIDATIONS_H_INCLUDED
22
23#include <xrpld/app/ledger/Ledger.h>
24#include <xrpld/consensus/Validations.h>
25
26#include <xrpl/protocol/Protocol.h>
27#include <xrpl/protocol/RippleLedgerHash.h>
28#include <xrpl/protocol/STValidation.h>
29
30#include <optional>
31#include <vector>
32
33namespace ripple {
34
35class Application;
36
37enum class BypassAccept : bool { no = false, yes };
38
44{
46
47public:
50
58
61 ledgerID() const
62 {
63 return val_->getLedgerHash();
64 }
65
68 seq() const
69 {
70 return val_->getFieldU32(sfLedgerSequence);
71 }
72
75 signTime() const
76 {
77 return val_->getSignTime();
78 }
79
82 seenTime() const
83 {
84 return val_->getSeenTime();
85 }
86
89 key() const
90 {
91 return val_->getSignerPublic();
92 }
93
95 NodeID
96 nodeID() const
97 {
98 return val_->getNodeID();
99 }
100
102 bool
103 trusted() const
104 {
105 return val_->isTrusted();
106 }
107
108 void
110 {
111 val_->setTrusted();
112 }
113
114 void
116 {
117 val_->setUntrusted();
118 }
119
121 bool
122 full() const
123 {
124 return val_->isFull();
125 }
126
129 loadFee() const
130 {
131 return ~(*val_)[~sfLoadFee];
132 }
133
136 cookie() const
137 {
138 return (*val_)[sfCookie];
139 }
140
143 unwrap() const
144 {
145 return val_;
146 }
147};
148
159{
160public:
161 using ID = LedgerHash;
164 {
165 explicit MakeGenesis() = default;
166 };
167
169
171 std::shared_ptr<Ledger const> const& ledger,
173
175 Seq
176 seq() const;
177
179 ID
180 id() const;
181
188 ID
189 operator[](Seq const& s) const;
190
192 friend Seq
194
195 Seq
196 minSeq() const;
197
198private:
203};
204
211{
212public:
213 // Type definitions for generic Validation
217
219
223 now() const;
224
227 acquire(LedgerHash const& id);
228
230 journal() const
231 {
232 return j_;
233 }
234
235private:
238};
239
242
252void
254 Application& app,
256 std::string const& source,
257 BypassAccept const bypassAccept = BypassAccept::no,
259
260} // namespace ripple
261
262#endif
A generic endpoint for log messages.
Definition Journal.h:60
A public key.
Definition PublicKey.h:62
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:25
std::uint32_t LedgerIndex
A ledger index.
Definition Protocol.h:139
base_uint< 160, detail::NodeIDTag > NodeID
NodeID is a 160-bit hash representing one node.
Definition UintTypes.h:59
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:45
@ yes
Definition Steps.h:45
uint256 LedgerHash