xrpld
Loading...
Searching...
No Matches
NetworkOPs.h
1#pragma once
2
3#include <xrpl/basics/base_uint.h>
4#include <xrpl/beast/clock/abstract_clock.h>
5#include <xrpl/core/ServiceRegistry.h>
6#include <xrpl/json/json_value.h>
7#include <xrpl/protocol/AccountID.h>
8#include <xrpl/protocol/Book.h>
9#include <xrpl/protocol/STValidation.h>
10#include <xrpl/protocol/TER.h>
11#include <xrpl/server/InfoSub.h>
12
13#include <boost/asio.hpp>
14
15#include <chrono>
16#include <cstddef>
17#include <cstdint>
18#include <memory>
19#include <optional>
20#include <sstream>
21#include <string>
22
23namespace xrpl {
24
25// Operations that clients may wish to perform against the network
26// Master operational handler, server sequencer, network tracker
27
28class Peer;
29class STTx;
30class ReadView;
31class LedgerMaster;
32class Transaction;
33class ValidatorKeys;
34class CanonicalTXSet;
35class RCLCxPeerPos;
36class SHAMap;
37
38// This is the primary interface into the "client" portion of the program.
39// Code that wants to do normal operations on the network such as
40// creating and monitoring accounts, creating transactions, and so on
41// should use this interface. The RPC code will primarily be a light wrapper
42// over this code.
43//
44// Eventually, it will check the node's operating mode (synced, unsynced,
45// etcetera) and defer to the correct means of processing. The current
46// code assumes this node is synced (and will continue to do so until
47// there's a functional network.
48//
49
60enum class OperatingMode {
63 SYNCING = 2,
65 FULL = 4
66};
67
82{
83public:
85
86 enum class FailHard : unsigned char { No, Yes };
87 static FailHard
88 doFailHard(bool noMeansDont)
89 {
90 return noMeansDont ? FailHard::Yes : FailHard::No;
91 }
92
93public:
94 ~NetworkOPs() override = default;
95
96 virtual void
97 stop() = 0;
98
99 //--------------------------------------------------------------------------
100 //
101 // Network information
102 //
103
104 [[nodiscard]] virtual OperatingMode
105 getOperatingMode() const = 0;
106 [[nodiscard]] virtual std::string
107 strOperatingMode(OperatingMode const mode, bool const admin = false) const = 0;
108 [[nodiscard]] virtual std::string
109 strOperatingMode(bool const admin = false) const = 0;
110
111 //--------------------------------------------------------------------------
112 //
113 // Transaction processing
114 //
115
116 // must complete immediately
117 virtual void
119
129 virtual void
131 std::shared_ptr<Transaction>& transaction,
132 bool bUnlimited,
133 bool bLocal,
134 FailHard failType) = 0;
135
142 virtual void
144
145 //--------------------------------------------------------------------------
146 //
147 // Owner functions
148 //
149
150 virtual json::Value
152
153 //--------------------------------------------------------------------------
154 //
155 // Book functions
156 //
157
158 virtual void
161 Book const& book,
162 AccountID const& uTakerID,
163 bool const bProof,
164 unsigned int iLimit,
165 json::Value const& jvMarker,
166 json::Value& jvResult) = 0;
167
168 //--------------------------------------------------------------------------
169
170 // ledger proposal/close functions
171 virtual bool
173
174 virtual bool
176
177 virtual void
178 mapComplete(std::shared_ptr<SHAMap> const& map, bool fromAcquire) = 0;
179
180 // network state machine
181 virtual bool
183 virtual void
185 virtual void
187 virtual void
189
190 virtual void
192 virtual void
194 virtual bool
196 virtual bool
197 isFull() = 0;
198 virtual void
200 virtual bool
202 virtual bool
204 virtual void
206 virtual bool
208 virtual void
210 virtual void
212 virtual bool
214 virtual void
216 virtual void
218 virtual void
220
221 virtual json::Value
223 virtual json::Value
224 getServerInfo(bool human, bool admin, bool counters) = 0;
225 virtual void
227 virtual json::Value
229
237 virtual std::uint32_t
238 acceptLedger(std::optional<std::chrono::milliseconds> consensusDelay = std::nullopt) = 0;
239
240 virtual void
242
243 virtual void
244 updateLocalTx(ReadView const& newValidLedger) = 0;
245 virtual std::size_t
247
248 //--------------------------------------------------------------------------
249 //
250 // Monitoring: publisher side
251 //
252 virtual void
254 virtual void
257 std::shared_ptr<STTx const> const& transaction,
258 TER result) = 0;
259 virtual void
261
262 virtual void
264
276 virtual std::size_t
278};
279
280} // namespace xrpl
Abstract interface to a clock.
Represents a JSON value.
Definition json_value.h:117
Specifies an order book.
Definition Book.h:28
Holds transactions which were deferred to the next pass of consensus.
Abstracts the source of subscription data.
Definition InfoSub.h:106
Provides server functionality for clients.
Definition NetworkOPs.h:82
virtual void getBookPage(std::shared_ptr< ReadView const > &lpLedger, Book const &book, AccountID const &uTakerID, bool const bProof, unsigned int iLimit, json::Value const &jvMarker, json::Value &jvResult)=0
virtual void setAmendmentBlocked()=0
virtual void setMode(OperatingMode om)=0
virtual bool isBlocked()=0
virtual bool isUNLBlocked()=0
virtual json::Value getConsensusInfo()=0
virtual json::Value getLedgerFetchInfo()=0
virtual void processTransactionSet(CanonicalTXSet const &set)=0
Process a set of transactions synchronously, and ensuring that they are processed in one batch.
virtual json::Value getOwnerInfo(std::shared_ptr< ReadView const > lpLedger, AccountID const &account)=0
virtual void consensusViewChange()=0
virtual void updateLocalTx(ReadView const &newValidLedger)=0
virtual std::size_t getLocalTxCount()=0
virtual void clearAmendmentWarned()=0
~NetworkOPs() override=default
virtual void submitTransaction(std::shared_ptr< STTx const > const &)=0
virtual void setNeedNetworkLedger()=0
beast::AbstractClock< std::chrono::steady_clock > clock_type
Definition NetworkOPs.h:84
virtual json::Value getServerInfo(bool human, bool admin, bool counters)=0
virtual void endConsensus(std::unique_ptr< std::stringstream > const &clog)=0
virtual bool recvValidation(std::shared_ptr< STValidation > const &val, std::string const &source)=0
virtual void pubProposedTransaction(std::shared_ptr< ReadView const > const &ledger, std::shared_ptr< STTx const > const &transaction, TER result)=0
virtual std::string strOperatingMode(bool const admin=false) const =0
virtual bool isAmendmentWarned()=0
virtual void reportFeeChange()=0
virtual void clearUNLBlocked()=0
virtual bool beginConsensus(uint256 const &netLCL, std::unique_ptr< std::stringstream > const &clog)=0
virtual void setUNLBlocked()=0
virtual void stop()=0
virtual void pubValidation(std::shared_ptr< STValidation > const &val)=0
virtual void pubLedger(std::shared_ptr< ReadView const > const &lpAccepted)=0
virtual bool isFull()=0
virtual OperatingMode getOperatingMode() const =0
virtual bool isNeedNetworkLedger()=0
virtual bool isAmendmentBlocked()=0
static FailHard doFailHard(bool noMeansDont)
Definition NetworkOPs.h:88
virtual void processTransaction(std::shared_ptr< Transaction > &transaction, bool bUnlimited, bool bLocal, FailHard failType)=0
Process transactions as they arrive from the network or which are submitted by clients.
virtual std::string strOperatingMode(OperatingMode const mode, bool const admin=false) const =0
virtual void clearNeedNetworkLedger()=0
virtual void stateAccounting(json::Value &obj)=0
virtual void setStateTimer()=0
virtual void clearLedgerFetch()=0
virtual std::uint32_t acceptLedger(std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)=0
Accepts the current transaction tree, return the new ledger's sequence.
virtual bool processTrustedProposal(RCLCxPeerPos peerPos)=0
virtual void setAmendmentWarned()=0
virtual void setStandAlone()=0
virtual void mapComplete(std::shared_ptr< SHAMap > const &map, bool fromAcquire)=0
virtual std::size_t getBookSubscribersCount()=0
Total number of (book, subscriber) entries currently tracked.
Represents a peer connection in the overlay.
A peer's signed, proposed position for use in RCLConsensus.
A view into a ledger.
Definition ReadView.h:41
Validator keys and manifest as set in configuration file.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
bool set(T &target, std::string const &name, Section const &section)
Set a value from a configuration Section If the named value is not found or doesn't parse as a T,...
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:34
TERSubset< CanCvtToTER > TER
Definition TER.h:647
OperatingMode
Specifies the mode under which the server believes it's operating.
Definition NetworkOPs.h:60
@ TRACKING
convinced we agree with the network
Definition NetworkOPs.h:64
@ DISCONNECTED
not ready to process requests
Definition NetworkOPs.h:61
@ CONNECTED
convinced we are talking to the network
Definition NetworkOPs.h:62
@ FULL
we have the ledger and can even validate
Definition NetworkOPs.h:65
@ SYNCING
fallen slightly behind
Definition NetworkOPs.h:63
BaseUInt< 256 > uint256
Definition base_uint.h:580