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
31#include <boost/asio.hpp>
32
33#include <memory>
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
184 uint256 const& netLCL,
185 std::unique_ptr<std::stringstream> const& clog) = 0;
186 virtual void
188 virtual void
190 virtual void
192
193 virtual void
195 virtual void
197 virtual bool
199 virtual bool
200 isFull() = 0;
201 virtual void
203 virtual bool
205 virtual bool
207 virtual void
209 virtual bool
211 virtual void
213 virtual void
215 virtual bool
217 virtual void
219 virtual void
221 virtual void
223
224 virtual Json::Value
226 virtual Json::Value
227 getServerInfo(bool human, bool admin, bool counters) = 0;
228 virtual void
230 virtual Json::Value
232
239 virtual std::uint32_t
242 std::nullopt) = 0;
243
244 virtual void
246
247 virtual void
248 updateLocalTx(ReadView const& newValidLedger) = 0;
249 virtual std::size_t
251
252 //--------------------------------------------------------------------------
253 //
254 // Monitoring: publisher side
255 //
256 virtual void
258 virtual void
261 std::shared_ptr<STTx const> const& transaction,
262 TER result) = 0;
263 virtual void
265
266 virtual void
268};
269
270//------------------------------------------------------------------------------
271
274 Application& app,
276 bool standalone,
277 std::size_t minPeerCount,
278 bool start_valid,
279 JobQueue& job_queue,
281 ValidatorKeys const& validatorKeys,
282 boost::asio::io_service& io_svc,
283 beast::Journal journal,
284 beast::insight::Collector::ptr const& collector);
285
286} // namespace ripple
287
288#endif
Represents a JSON value.
Definition: json_value.h:148
A generic endpoint for log messages.
Definition: Journal.h:60
Specifies an order book.
Definition: Book.h:35
Abstracts the source of subscription data.
Definition: InfoSub.h:67
A pool of threads to perform work.
Definition: JobQueue.h:55
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 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 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:43
A view into a ledger.
Definition: ReadView.h:51
Validator keys and manifest as set in configuration file.
Definition: ValidatorKeys.h:38
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