rippled
Loading...
Searching...
No Matches
NetworkOPs.h
1#ifndef XRPL_APP_MISC_NETWORKOPS_H_INCLUDED
2#define XRPL_APP_MISC_NETWORKOPS_H_INCLUDED
3
4#include <xrpld/app/consensus/RCLCxPeerPos.h>
5#include <xrpld/app/ledger/Ledger.h>
6#include <xrpld/core/JobQueue.h>
7#include <xrpld/rpc/InfoSub.h>
8
9#include <xrpl/ledger/ReadView.h>
10#include <xrpl/protocol/STValidation.h>
11#include <xrpl/protocol/messages.h>
12
13#include <boost/asio.hpp>
14
15#include <memory>
16
17namespace ripple {
18
19// Operations that clients may wish to perform against the network
20// Master operational handler, server sequencer, network tracker
21
22class Peer;
23class LedgerMaster;
24class Transaction;
25class ValidatorKeys;
26class CanonicalTXSet;
27
28// This is the primary interface into the "client" portion of the program.
29// Code that wants to do normal operations on the network such as
30// creating and monitoring accounts, creating transactions, and so on
31// should use this interface. The RPC code will primarily be a light wrapper
32// over this code.
33//
34// Eventually, it will check the node's operating mode (synched, unsynched,
35// etectera) and defer to the correct means of processing. The current
36// code assumes this node is synched (and will continue to do so until
37// there's a functional network.
38//
39
49enum class OperatingMode {
50 DISCONNECTED = 0,
51 CONNECTED = 1,
52 SYNCING = 2,
53 TRACKING = 3,
54 FULL = 4
55};
56
70{
71public:
73
74 enum class FailHard : unsigned char { no, yes };
75 static inline FailHard
76 doFailHard(bool noMeansDont)
77 {
78 return noMeansDont ? FailHard::yes : FailHard::no;
79 }
80
81public:
82 ~NetworkOPs() override = default;
83
84 virtual void
85 stop() = 0;
86
87 //--------------------------------------------------------------------------
88 //
89 // Network information
90 //
91
92 virtual OperatingMode
93 getOperatingMode() const = 0;
94 virtual std::string
95 strOperatingMode(OperatingMode const mode, bool const admin = false)
96 const = 0;
97 virtual std::string
98 strOperatingMode(bool const admin = false) const = 0;
99
100 //--------------------------------------------------------------------------
101 //
102 // Transaction processing
103 //
104
105 // must complete immediately
106 virtual void
108
118 virtual void
120 std::shared_ptr<Transaction>& transaction,
121 bool bUnlimited,
122 bool bLocal,
123 FailHard failType) = 0;
124
131 virtual void
133
134 //--------------------------------------------------------------------------
135 //
136 // Owner functions
137 //
138
139 virtual Json::Value
142 AccountID const& account) = 0;
143
144 //--------------------------------------------------------------------------
145 //
146 // Book functions
147 //
148
149 virtual void
152 Book const& book,
153 AccountID const& uTakerID,
154 bool const bProof,
155 unsigned int iLimit,
156 Json::Value const& jvMarker,
157 Json::Value& jvResult) = 0;
158
159 //--------------------------------------------------------------------------
160
161 // ledger proposal/close functions
162 virtual bool
164
165 virtual bool
168 std::string const& source) = 0;
169
170 virtual void
171 mapComplete(std::shared_ptr<SHAMap> const& map, bool fromAcquire) = 0;
172
173 // network state machine
174 virtual bool
176 uint256 const& netLCL,
177 std::unique_ptr<std::stringstream> const& clog) = 0;
178 virtual void
180 virtual void
182 virtual void
184
185 virtual void
187 virtual void
189 virtual bool
191 virtual bool
192 isFull() = 0;
193 virtual void
195 virtual bool
197 virtual bool
199 virtual void
201 virtual bool
203 virtual void
205 virtual void
207 virtual bool
209 virtual void
211 virtual void
213 virtual void
215
216 virtual Json::Value
218 virtual Json::Value
219 getServerInfo(bool human, bool admin, bool counters) = 0;
220 virtual void
222 virtual Json::Value
224
231 virtual std::uint32_t
234 std::nullopt) = 0;
235
236 virtual void
238
239 virtual void
240 updateLocalTx(ReadView const& newValidLedger) = 0;
241 virtual std::size_t
243
244 //--------------------------------------------------------------------------
245 //
246 // Monitoring: publisher side
247 //
248 virtual void
250 virtual void
253 std::shared_ptr<STTx const> const& transaction,
254 TER result) = 0;
255 virtual void
257
258 virtual void
260};
261
262//------------------------------------------------------------------------------
263
266 Application& app,
268 bool standalone,
269 std::size_t minPeerCount,
270 bool start_valid,
271 JobQueue& job_queue,
273 ValidatorKeys const& validatorKeys,
274 boost::asio::io_context& io_svc,
275 beast::Journal journal,
276 beast::insight::Collector::ptr const& collector);
277
278} // namespace ripple
279
280#endif
Represents a JSON value.
Definition json_value.h:131
A generic endpoint for log messages.
Definition Journal.h:41
Specifies an order book.
Definition Book.h:17
Holds transactions which were deferred to the next pass of consensus.
Abstracts the source of subscription data.
Definition InfoSub.h:49
A pool of threads to perform work.
Definition JobQueue.h:39
Provides server functionality for clients.
Definition NetworkOPs.h:70
virtual Json::Value getOwnerInfo(std::shared_ptr< ReadView const > lpLedger, AccountID const &account)=0
static FailHard doFailHard(bool noMeansDont)
Definition NetworkOPs.h:76
virtual void endConsensus(std::unique_ptr< std::stringstream > const &clog)=0
virtual bool isBlocked()=0
virtual void setAmendmentWarned()=0
virtual void setUNLBlocked()=0
virtual void submitTransaction(std::shared_ptr< STTx const > const &)=0
virtual OperatingMode getOperatingMode() const =0
virtual void stateAccounting(Json::Value &obj)=0
virtual void pubValidation(std::shared_ptr< STValidation > const &val)=0
virtual void pubProposedTransaction(std::shared_ptr< ReadView const > const &ledger, std::shared_ptr< STTx const > const &transaction, TER result)=0
virtual void mapComplete(std::shared_ptr< SHAMap > const &map, bool fromAcquire)=0
virtual Json::Value getConsensusInfo()=0
virtual void setAmendmentBlocked()=0
virtual void stop()=0
virtual void setStandAlone()=0
virtual void consensusViewChange()=0
virtual void clearLedgerFetch()=0
virtual void clearNeedNetworkLedger()=0
virtual void setNeedNetworkLedger()=0
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 bool recvValidation(std::shared_ptr< STValidation > const &val, std::string const &source)=0
virtual bool processTrustedProposal(RCLCxPeerPos peerPos)=0
virtual std::string strOperatingMode(bool const admin=false) const =0
virtual std::size_t getLocalTxCount()=0
~NetworkOPs() override=default
virtual bool beginConsensus(uint256 const &netLCL, std::unique_ptr< std::stringstream > const &clog)=0
virtual void reportFeeChange()=0
virtual bool isFull()=0
virtual bool isAmendmentWarned()=0
virtual void setMode(OperatingMode om)=0
virtual void clearUNLBlocked()=0
virtual std::string strOperatingMode(OperatingMode const mode, bool const admin=false) const =0
virtual bool isNeedNetworkLedger()=0
virtual bool isAmendmentBlocked()=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 Json::Value getLedgerFetchInfo()=0
virtual void updateLocalTx(ReadView const &newValidLedger)=0
virtual void clearAmendmentWarned()=0
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 Json::Value getServerInfo(bool human, bool admin, bool counters)=0
virtual void setStateTimer()=0
virtual void processTransactionSet(CanonicalTXSet const &set)=0
Process a set of transactions synchronously, and ensuring that they are processed in one batch.
virtual void pubLedger(std::shared_ptr< ReadView const > const &lpAccepted)=0
virtual bool isUNLBlocked()=0
A peer's signed, proposed position for use in RCLConsensus.
A view into a ledger.
Definition ReadView.h:32
Validator keys and manifest as set in configuration file.
T is_same_v
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
std::unique_ptr< NetworkOPs > make_NetworkOPs(Application &app, NetworkOPs::clock_type &clock, bool standalone, std::size_t minPeerCount, bool startvalid, JobQueue &job_queue, LedgerMaster &ledgerMaster, ValidatorKeys const &validatorKeys, boost::asio::io_context &io_svc, beast::Journal journal, beast::insight::Collector::ptr const &collector)
OperatingMode
Specifies the mode under which the server believes it's operating.
Definition NetworkOPs.h:49
@ TRACKING
convinced we agree with the network
@ DISCONNECTED
not ready to process requests
@ CONNECTED
convinced we are talking to the network
@ FULL
we have the ledger and can even validate
@ SYNCING
fallen slightly behind
@ ledgerMaster
ledger master data for signing