rippled
Loading...
Searching...
No Matches
NetworkOPs.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_MISC_NETWORKOPS_H_INCLUDED
21#define RIPPLE_APP_MISC_NETWORKOPS_H_INCLUDED
22
23#include <xrpld/app/consensus/RCLCxPeerPos.h>
24#include <xrpld/app/ledger/Ledger.h>
25#include <xrpld/core/JobQueue.h>
26#include <xrpld/rpc/InfoSub.h>
27
28#include <xrpl/ledger/ReadView.h>
29#include <xrpl/protocol/STValidation.h>
30#include <xrpl/protocol/messages.h>
31
32#include <boost/asio.hpp>
33
34#include <memory>
35
36namespace ripple {
37
38// Operations that clients may wish to perform against the network
39// Master operational handler, server sequencer, network tracker
40
41class Peer;
42class LedgerMaster;
43class Transaction;
44class ValidatorKeys;
45class CanonicalTXSet;
46
47// This is the primary interface into the "client" portion of the program.
48// Code that wants to do normal operations on the network such as
49// creating and monitoring accounts, creating transactions, and so on
50// should use this interface. The RPC code will primarily be a light wrapper
51// over this code.
52//
53// Eventually, it will check the node's operating mode (synched, unsynched,
54// etectera) and defer to the correct means of processing. The current
55// code assumes this node is synched (and will continue to do so until
56// there's a functional network.
57//
58
68enum class OperatingMode {
69 DISCONNECTED = 0,
70 CONNECTED = 1,
71 SYNCING = 2,
72 TRACKING = 3,
73 FULL = 4
74};
75
89{
90public:
92
93 enum class FailHard : unsigned char { no, yes };
94 static inline FailHard
95 doFailHard(bool noMeansDont)
96 {
97 return noMeansDont ? FailHard::yes : FailHard::no;
98 }
99
100public:
101 ~NetworkOPs() override = default;
102
103 virtual void
104 stop() = 0;
105
106 //--------------------------------------------------------------------------
107 //
108 // Network information
109 //
110
111 virtual OperatingMode
112 getOperatingMode() const = 0;
113 virtual std::string
114 strOperatingMode(OperatingMode const mode, bool const admin = false)
115 const = 0;
116 virtual std::string
117 strOperatingMode(bool const admin = false) const = 0;
118
119 //--------------------------------------------------------------------------
120 //
121 // Transaction processing
122 //
123
124 // must complete immediately
125 virtual void
127
137 virtual void
139 std::shared_ptr<Transaction>& transaction,
140 bool bUnlimited,
141 bool bLocal,
142 FailHard failType) = 0;
143
150 virtual void
152
153 //--------------------------------------------------------------------------
154 //
155 // Owner functions
156 //
157
158 virtual Json::Value
161 AccountID const& account) = 0;
162
163 //--------------------------------------------------------------------------
164 //
165 // Book functions
166 //
167
168 virtual void
171 Book const& book,
172 AccountID const& uTakerID,
173 bool const bProof,
174 unsigned int iLimit,
175 Json::Value const& jvMarker,
176 Json::Value& jvResult) = 0;
177
178 //--------------------------------------------------------------------------
179
180 // ledger proposal/close functions
181 virtual bool
183
184 virtual bool
187 std::string const& source) = 0;
188
189 virtual void
190 mapComplete(std::shared_ptr<SHAMap> const& map, bool fromAcquire) = 0;
191
192 // network state machine
193 virtual bool
195 uint256 const& netLCL,
196 std::unique_ptr<std::stringstream> const& clog) = 0;
197 virtual void
199 virtual void
201 virtual void
203
204 virtual void
206 virtual void
208 virtual bool
210 virtual bool
211 isFull() = 0;
212 virtual void
214 virtual bool
216 virtual bool
218 virtual void
220 virtual bool
222 virtual void
224 virtual void
226 virtual bool
228 virtual void
230 virtual void
232 virtual void
234
235 virtual Json::Value
237 virtual Json::Value
238 getServerInfo(bool human, bool admin, bool counters) = 0;
239 virtual void
241 virtual Json::Value
243
250 virtual std::uint32_t
253 std::nullopt) = 0;
254
255 virtual void
257
258 virtual void
259 updateLocalTx(ReadView const& newValidLedger) = 0;
260 virtual std::size_t
262
263 //--------------------------------------------------------------------------
264 //
265 // Monitoring: publisher side
266 //
267 virtual void
269 virtual void
272 std::shared_ptr<STTx const> const& transaction,
273 TER result) = 0;
274 virtual void
276
277 virtual void
279};
280
281//------------------------------------------------------------------------------
282
285 Application& app,
287 bool standalone,
288 std::size_t minPeerCount,
289 bool start_valid,
290 JobQueue& job_queue,
292 ValidatorKeys const& validatorKeys,
293 boost::asio::io_context& io_svc,
294 beast::Journal journal,
295 beast::insight::Collector::ptr const& collector);
296
297} // namespace ripple
298
299#endif
Represents a JSON value.
Definition json_value.h:149
A generic endpoint for log messages.
Definition Journal.h:60
Specifies an order book.
Definition Book.h:36
Holds transactions which were deferred to the next pass of consensus.
Abstracts the source of subscription data.
Definition InfoSub.h:68
A pool of threads to perform work.
Definition JobQueue.h:58
Provides server functionality for clients.
Definition NetworkOPs.h:89
virtual Json::Value getOwnerInfo(std::shared_ptr< ReadView const > lpLedger, AccountID const &account)=0
static FailHard doFailHard(bool noMeansDont)
Definition NetworkOPs.h:95
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:51
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:25
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:68
@ 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