rippled
Loading...
Searching...
No Matches
NetworkOPs.h
1#pragma once
2
3#include <xrpl/core/JobQueue.h>
4#include <xrpl/core/ServiceRegistry.h>
5#include <xrpl/protocol/STValidation.h>
6#include <xrpl/protocol/TER.h>
7#include <xrpl/protocol/messages.h>
8#include <xrpl/server/InfoSub.h>
9#include <xrpl/shamap/SHAMap.h>
10
11#include <boost/asio.hpp>
12
13#include <memory>
14
15namespace xrpl {
16
17// Operations that clients may wish to perform against the network
18// Master operational handler, server sequencer, network tracker
19
20class Peer;
21class STTx;
22class ReadView;
23class LedgerMaster;
24class Transaction;
25class ValidatorKeys;
26class CanonicalTXSet;
27class RCLCxPeerPos;
28
29// This is the primary interface into the "client" portion of the program.
30// Code that wants to do normal operations on the network such as
31// creating and monitoring accounts, creating transactions, and so on
32// should use this interface. The RPC code will primarily be a light wrapper
33// over this code.
34//
35// Eventually, it will check the node's operating mode (synced, unsynced,
36// etcetera) and defer to the correct means of processing. The current
37// code assumes this node is synced (and will continue to do so until
38// there's a functional network.
39//
40
50enum class OperatingMode {
51 DISCONNECTED = 0,
52 CONNECTED = 1,
53 SYNCING = 2,
54 TRACKING = 3,
55 FULL = 4
56};
57
71{
72public:
74
75 enum class FailHard : unsigned char { no, yes };
76 static inline FailHard
77 doFailHard(bool noMeansDont)
78 {
79 return noMeansDont ? FailHard::yes : FailHard::no;
80 }
81
82public:
83 ~NetworkOPs() override = default;
84
85 virtual void
86 stop() = 0;
87
88 //--------------------------------------------------------------------------
89 //
90 // Network information
91 //
92
93 virtual OperatingMode
94 getOperatingMode() const = 0;
95 virtual std::string
96 strOperatingMode(OperatingMode const mode, bool const admin = false) 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
141
142 //--------------------------------------------------------------------------
143 //
144 // Book functions
145 //
146
147 virtual void
150 Book const& book,
151 AccountID const& uTakerID,
152 bool const bProof,
153 unsigned int iLimit,
154 Json::Value const& jvMarker,
155 Json::Value& jvResult) = 0;
156
157 //--------------------------------------------------------------------------
158
159 // ledger proposal/close functions
160 virtual bool
162
163 virtual bool
165
166 virtual void
167 mapComplete(std::shared_ptr<SHAMap> const& map, bool fromAcquire) = 0;
168
169 // network state machine
170 virtual bool
172 virtual void
174 virtual void
176 virtual void
178
179 virtual void
181 virtual void
183 virtual bool
185 virtual bool
186 isFull() = 0;
187 virtual void
189 virtual bool
191 virtual bool
193 virtual void
195 virtual bool
197 virtual void
199 virtual void
201 virtual bool
203 virtual void
205 virtual void
207 virtual void
209
210 virtual Json::Value
212 virtual Json::Value
213 getServerInfo(bool human, bool admin, bool counters) = 0;
214 virtual void
216 virtual Json::Value
218
225 virtual std::uint32_t
227
228 virtual void
230
231 virtual void
232 updateLocalTx(ReadView const& newValidLedger) = 0;
233 virtual std::size_t
235
236 //--------------------------------------------------------------------------
237 //
238 // Monitoring: publisher side
239 //
240 virtual void
242 virtual void
245 std::shared_ptr<STTx const> const& transaction,
246 TER result) = 0;
247 virtual void
249
250 virtual void
252};
253
254} // namespace xrpl
Represents a JSON value.
Definition json_value.h:130
Specifies an order book.
Definition Book.h:16
Holds transactions which were deferred to the next pass of consensus.
Abstracts the source of subscription data.
Definition InfoSub.h:47
Provides server functionality for clients.
Definition NetworkOPs.h:71
virtual void setAmendmentBlocked()=0
virtual void setMode(OperatingMode om)=0
virtual bool isBlocked()=0
virtual bool isUNLBlocked()=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 consensusViewChange()=0
virtual void updateLocalTx(ReadView const &newValidLedger)=0
virtual std::size_t getLocalTxCount()=0
virtual Json::Value getOwnerInfo(std::shared_ptr< ReadView const > lpLedger, AccountID const &account)=0
virtual void clearAmendmentWarned()=0
~NetworkOPs() override=default
virtual void submitTransaction(std::shared_ptr< STTx const > const &)=0
virtual void setNeedNetworkLedger()=0
virtual void endConsensus(std::unique_ptr< std::stringstream > const &clog)=0
virtual bool recvValidation(std::shared_ptr< STValidation > const &val, std::string const &source)=0
virtual void pubProposedTransaction(std::shared_ptr< ReadView const > const &ledger, std::shared_ptr< STTx const > const &transaction, TER result)=0
virtual std::string strOperatingMode(bool const admin=false) const =0
virtual bool isAmendmentWarned()=0
virtual void reportFeeChange()=0
virtual void clearUNLBlocked()=0
virtual bool beginConsensus(uint256 const &netLCL, std::unique_ptr< std::stringstream > const &clog)=0
virtual Json::Value getLedgerFetchInfo()=0
virtual void setUNLBlocked()=0
virtual void stop()=0
virtual void pubValidation(std::shared_ptr< STValidation > const &val)=0
virtual void pubLedger(std::shared_ptr< ReadView const > const &lpAccepted)=0
virtual bool isFull()=0
virtual OperatingMode getOperatingMode() const =0
virtual bool isNeedNetworkLedger()=0
virtual Json::Value getConsensusInfo()=0
virtual bool isAmendmentBlocked()=0
static FailHard doFailHard(bool noMeansDont)
Definition NetworkOPs.h:77
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 std::string strOperatingMode(OperatingMode const mode, bool const admin=false) const =0
virtual void clearNeedNetworkLedger()=0
virtual void setStateTimer()=0
virtual void stateAccounting(Json::Value &obj)=0
virtual void clearLedgerFetch()=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 getServerInfo(bool human, bool admin, bool counters)=0
virtual bool processTrustedProposal(RCLCxPeerPos peerPos)=0
virtual void setAmendmentWarned()=0
virtual void setStandAlone()=0
virtual void mapComplete(std::shared_ptr< SHAMap > const &map, bool fromAcquire)=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
A peer's signed, proposed position for use in RCLConsensus.
A view into a ledger.
Definition ReadView.h:31
T is_same_v
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
OperatingMode
Specifies the mode under which the server believes it's operating.
Definition NetworkOPs.h:50
@ 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