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
119 processTransaction(std::shared_ptr<Transaction>& transaction, bool bUnlimited, bool bLocal, FailHard failType) = 0;
120
127 virtual void
129
130 //--------------------------------------------------------------------------
131 //
132 // Owner functions
133 //
134
135 virtual Json::Value
137
138 //--------------------------------------------------------------------------
139 //
140 // Book functions
141 //
142
143 virtual void
146 Book const& book,
147 AccountID const& uTakerID,
148 bool const bProof,
149 unsigned int iLimit,
150 Json::Value const& jvMarker,
151 Json::Value& jvResult) = 0;
152
153 //--------------------------------------------------------------------------
154
155 // ledger proposal/close functions
156 virtual bool
158
159 virtual bool
161
162 virtual void
163 mapComplete(std::shared_ptr<SHAMap> const& map, bool fromAcquire) = 0;
164
165 // network state machine
166 virtual bool
168 virtual void
170 virtual void
172 virtual void
174
175 virtual void
177 virtual void
179 virtual bool
181 virtual bool
182 isFull() = 0;
183 virtual void
185 virtual bool
187 virtual bool
189 virtual void
191 virtual bool
193 virtual void
195 virtual void
197 virtual bool
199 virtual void
201 virtual void
203 virtual void
205
206 virtual Json::Value
208 virtual Json::Value
209 getServerInfo(bool human, bool admin, bool counters) = 0;
210 virtual void
212 virtual Json::Value
214
221 virtual std::uint32_t
223
224 virtual void
226
227 virtual void
228 updateLocalTx(ReadView const& newValidLedger) = 0;
229 virtual std::size_t
231
232 //--------------------------------------------------------------------------
233 //
234 // Monitoring: publisher side
235 //
236 virtual void
238 virtual void
241 std::shared_ptr<STTx const> const& transaction,
242 TER result) = 0;
243 virtual void
245
246 virtual void
248};
249
250} // 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