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/ledger/ReadView.h>
27#include <xrpld/net/InfoSub.h>
28#include <xrpl/protocol/STValidation.h>
29#include <xrpl/protocol/messages.h>
30#include <boost/asio.hpp>
31#include <deque>
32#include <memory>
33#include <tuple>
34
35namespace ripple {
36
37// Operations that clients may wish to perform against the network
38// Master operational handler, server sequencer, network tracker
39
40class Peer;
41class LedgerMaster;
42class Transaction;
43class ValidatorKeys;
44
45// This is the primary interface into the "client" portion of the program.
46// Code that wants to do normal operations on the network such as
47// creating and monitoring accounts, creating transactions, and so on
48// should use this interface. The RPC code will primarily be a light wrapper
49// over this code.
50//
51// Eventually, it will check the node's operating mode (synched, unsynched,
52// etectera) and defer to the correct means of processing. The current
53// code assumes this node is synched (and will continue to do so until
54// there's a functional network.
55//
56
66enum class OperatingMode {
67 DISCONNECTED = 0,
68 CONNECTED = 1,
69 SYNCING = 2,
70 TRACKING = 3,
71 FULL = 4
72};
73
87{
88public:
90
91 enum class FailHard : unsigned char { no, yes };
92 static inline FailHard
93 doFailHard(bool noMeansDont)
94 {
95 return noMeansDont ? FailHard::yes : FailHard::no;
96 }
97
98public:
99 ~NetworkOPs() override = default;
100
101 virtual void
102 stop() = 0;
103
104 //--------------------------------------------------------------------------
105 //
106 // Network information
107 //
108
109 virtual OperatingMode
110 getOperatingMode() const = 0;
111 virtual std::string
112 strOperatingMode(OperatingMode const mode, bool const admin = false)
113 const = 0;
114 virtual std::string
115 strOperatingMode(bool const admin = false) const = 0;
116
117 //--------------------------------------------------------------------------
118 //
119 // Transaction processing
120 //
121
122 // must complete immediately
123 virtual void
125
135 virtual void
137 std::shared_ptr<Transaction>& transaction,
138 bool bUnlimited,
139 bool bLocal,
140 FailHard failType) = 0;
141
142 //--------------------------------------------------------------------------
143 //
144 // Owner functions
145 //
146
147 virtual Json::Value
150 AccountID const& account) = 0;
151
152 //--------------------------------------------------------------------------
153 //
154 // Book functions
155 //
156
157 virtual void
160 Book const& book,
161 AccountID const& uTakerID,
162 bool const bProof,
163 unsigned int iLimit,
164 Json::Value const& jvMarker,
165 Json::Value& jvResult) = 0;
166
167 //--------------------------------------------------------------------------
168
169 // ledger proposal/close functions
170 virtual bool
172
173 virtual bool
176 std::string const& source) = 0;
177
178 virtual void
179 mapComplete(std::shared_ptr<SHAMap> const& map, bool fromAcquire) = 0;
180
181 // network state machine
182 virtual bool
183 beginConsensus(uint256 const& netLCL) = 0;
184 virtual void
186 virtual void
188 virtual void
190
191 virtual void
193 virtual void
195 virtual bool
197 virtual bool
198 isFull() = 0;
199 virtual void
201 virtual bool
203 virtual bool
205 virtual void
207 virtual bool
209 virtual void
211 virtual void
213 virtual bool
215 virtual void
217 virtual void
219 virtual void
221
222 virtual Json::Value
224 virtual Json::Value
225 getServerInfo(bool human, bool admin, bool counters) = 0;
226 virtual void
228 virtual Json::Value
230
237 virtual std::uint32_t
240 std::nullopt) = 0;
241
242 virtual void
244
245 virtual void
246 updateLocalTx(ReadView const& newValidLedger) = 0;
247 virtual std::size_t
249
250 //--------------------------------------------------------------------------
251 //
252 // Monitoring: publisher side
253 //
254 virtual void
256 virtual void
259 std::shared_ptr<STTx const> const& transaction,
260 TER result) = 0;
261 virtual void
263
264 virtual void
266};
267
268//------------------------------------------------------------------------------
269
272 Application& app,
274 bool standalone,
275 std::size_t minPeerCount,
276 bool start_valid,
277 JobQueue& job_queue,
279 ValidatorKeys const& validatorKeys,
280 boost::asio::io_service& io_svc,
281 beast::Journal journal,
282 beast::insight::Collector::ptr const& collector);
283
284} // namespace ripple
285
286#endif
Represents a JSON value.
Definition: json_value.h:147
A generic endpoint for log messages.
Definition: Journal.h:59
Specifies an order book.
Definition: Book.h:34
Abstracts the source of subscription data.
Definition: InfoSub.h:68
A pool of threads to perform work.
Definition: JobQueue.h:56
Provides server functionality for clients.
Definition: NetworkOPs.h:87
virtual Json::Value getOwnerInfo(std::shared_ptr< ReadView const > lpLedger, AccountID const &account)=0
static FailHard doFailHard(bool noMeansDont)
Definition: NetworkOPs.h:93
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 bool beginConsensus(uint256 const &netLCL)=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 void reportFeeChange()=0
virtual bool isFull()=0
virtual bool isAmendmentWarned()=0
virtual void setMode(OperatingMode om)=0
virtual void clearUNLBlocked()=0
virtual void endConsensus()=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 pubLedger(std::shared_ptr< ReadView const > const &lpAccepted)=0
virtual bool isUNLBlocked()=0
A peer's signed, proposed position for use in RCLConsensus.
Definition: RCLCxPeerPos.h:44
A view into a ledger.
Definition: ReadView.h:55
Validator keys and manifest as set in configuration file.
Definition: ValidatorKeys.h:37
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
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_service &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:66
@ 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