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#include <xrpl/protocol/Protocol.h>
26#include <xrpl/protocol/RippleLedgerHash.h>
27#include <xrpl/protocol/STValidation.h>
28#include <optional>
29#include <set>
30#include <vector>
31
32namespace ripple {
33
34class Application;
35
36enum class BypassAccept : bool { no = false, yes };
37
43{
45
46public:
49
55 {
56 }
57
60 ledgerID() const
61 {
62 return val_->getLedgerHash();
63 }
64
67 seq() const
68 {
69 return val_->getFieldU32(sfLedgerSequence);
70 }
71
74 signTime() const
75 {
76 return val_->getSignTime();
77 }
78
81 seenTime() const
82 {
83 return val_->getSeenTime();
84 }
85
88 key() const
89 {
90 return val_->getSignerPublic();
91 }
92
94 NodeID
95 nodeID() const
96 {
97 return val_->getNodeID();
98 }
99
101 bool
102 trusted() const
103 {
104 return val_->isTrusted();
105 }
106
107 void
109 {
110 val_->setTrusted();
111 }
112
113 void
115 {
116 val_->setUntrusted();
117 }
118
120 bool
121 full() const
122 {
123 return val_->isFull();
124 }
125
128 loadFee() const
129 {
130 return ~(*val_)[~sfLoadFee];
131 }
132
135 cookie() const
136 {
137 return (*val_)[sfCookie];
138 }
139
142 unwrap() const
143 {
144 return val_;
145 }
146};
147
158{
159public:
160 using ID = LedgerHash;
163 {
164 explicit MakeGenesis() = default;
165 };
166
168
170 std::shared_ptr<Ledger const> const& ledger,
172
174 Seq
175 seq() const;
176
178 ID
179 id() const;
180
187 ID
188 operator[](Seq const& s) const;
189
191 friend Seq
193
194 Seq
195 minSeq() const;
196
197private:
202};
203
210{
211public:
212 // Type definitions for generic Validation
216
218
222 now() const;
223
226 acquire(LedgerHash const& id);
227
229 journal() const
230 {
231 return j_;
232 }
233
234private:
237};
238
241
251void
253 Application& app,
255 std::string const& source,
256 BypassAccept const bypassAccept = BypassAccept::no,
257 std::optional<beast::Journal> j = std::nullopt);
258
259} // namespace ripple
260
261#endif
A generic endpoint for log messages.
Definition: Journal.h:59
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.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
std::uint32_t LedgerIndex
A ledger index.
Definition: Protocol.h:119
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:42
@ yes
Definition: Steps.h:42
uint256 LedgerHash