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
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;
45
46// This is the primary interface into the "client" portion of the program.
47// Code that wants to do normal operations on the network such as
48// creating and monitoring accounts, creating transactions, and so on
49// should use this interface. The RPC code will primarily be a light wrapper
50// over this code.
51//
52// Eventually, it will check the node's operating mode (synched, unsynched,
53// etectera) and defer to the correct means of processing. The current
54// code assumes this node is synched (and will continue to do so until
55// there's a functional network.
56//
57
67enum class OperatingMode {
68 DISCONNECTED = 0,
69 CONNECTED = 1,
70 SYNCING = 2,
71 TRACKING = 3,
72 FULL = 4
73};
74
88{
89public:
91
92 enum class FailHard : unsigned char { no, yes };
93 static inline FailHard
94 doFailHard(bool noMeansDont)
95 {
96 return noMeansDont ? FailHard::yes : FailHard::no;
97 }
98
99public:
100 ~NetworkOPs() override = default;
101
102 virtual void
103 stop() = 0;
104
105 //--------------------------------------------------------------------------
106 //
107 // Network information
108 //
109
110 virtual OperatingMode
111 getOperatingMode() const = 0;
112 virtual std::string
113 strOperatingMode(OperatingMode const mode, bool const admin = false)
114 const = 0;
115 virtual std::string
116 strOperatingMode(bool const admin = false) const = 0;
117
118 //--------------------------------------------------------------------------
119 //
120 // Transaction processing
121 //
122
123 // must complete immediately
124 virtual void
126
136 virtual void
138 std::shared_ptr<Transaction>& transaction,
139 bool bUnlimited,
140 bool bLocal,
141 FailHard failType) = 0;
142
143 //--------------------------------------------------------------------------
144 //
145 // Owner functions
146 //
147
148 virtual Json::Value
151 AccountID const& account) = 0;
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
177 std::string const& source) = 0;
178
179 virtual void
180 mapComplete(std::shared_ptr<SHAMap> const& map, bool fromAcquire) = 0;
181
182 // network state machine
183 virtual bool
185 uint256 const& netLCL,
186 std::unique_ptr<std::stringstream> const& clog) = 0;
187 virtual void
189 virtual void
191 virtual void
193
194 virtual void
196 virtual void
198 virtual bool
200 virtual bool
201 isFull() = 0;
202 virtual void
204 virtual bool
206 virtual bool
208 virtual void
210 virtual bool
212 virtual void
214 virtual void
216 virtual bool
218 virtual void
220 virtual void
222 virtual void
224
225 virtual Json::Value
227 virtual Json::Value
228 getServerInfo(bool human, bool admin, bool counters) = 0;
229 virtual void
231 virtual Json::Value
233
240 virtual std::uint32_t
243 std::nullopt) = 0;
244
245 virtual void
247
248 virtual void
249 updateLocalTx(ReadView const& newValidLedger) = 0;
250 virtual std::size_t
252
253 //--------------------------------------------------------------------------
254 //
255 // Monitoring: publisher side
256 //
257 virtual void
259 virtual void
262 std::shared_ptr<STTx const> const& transaction,
263 TER result) = 0;
264 virtual void
266
267 virtual void
269};
270
271//------------------------------------------------------------------------------
272
275 Application& app,
277 bool standalone,
278 std::size_t minPeerCount,
279 bool start_valid,
280 JobQueue& job_queue,
282 ValidatorKeys const& validatorKeys,
283 boost::asio::io_service& io_svc,
284 beast::Journal journal,
285 beast::insight::Collector::ptr const& collector);
286
287} // namespace ripple
288
289#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:68
A pool of threads to perform work.
Definition: JobQueue.h:56
Provides server functionality for clients.
Definition: NetworkOPs.h:88
virtual Json::Value getOwnerInfo(std::shared_ptr< ReadView const > lpLedger, AccountID const &account)=0
static FailHard doFailHard(bool noMeansDont)
Definition: NetworkOPs.h:94
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:44
A view into a ledger.
Definition: ReadView.h:52
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:67
@ 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