rippled
NetworkOPs.cpp
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 #include <ripple/app/misc/NetworkOPs.h>
21 #include <ripple/consensus/Consensus.h>
22 #include <ripple/app/consensus/RCLConsensus.h>
23 #include <ripple/app/consensus/RCLValidations.h>
24 #include <ripple/app/ledger/AcceptedLedger.h>
25 #include <ripple/app/ledger/InboundLedgers.h>
26 #include <ripple/app/ledger/LedgerMaster.h>
27 #include <ripple/consensus/ConsensusParms.h>
28 #include <ripple/app/ledger/LedgerToJson.h>
29 #include <ripple/app/ledger/LocalTxs.h>
30 #include <ripple/app/ledger/OpenLedger.h>
31 #include <ripple/app/ledger/OrderBookDB.h>
32 #include <ripple/app/ledger/TransactionMaster.h>
33 #include <ripple/app/main/LoadManager.h>
34 #include <ripple/app/misc/AmendmentTable.h>
35 #include <ripple/app/misc/HashRouter.h>
36 #include <ripple/app/misc/LoadFeeTrack.h>
37 #include <ripple/app/misc/Transaction.h>
38 #include <ripple/app/misc/TxQ.h>
39 #include <ripple/app/misc/ValidatorKeys.h>
40 #include <ripple/app/misc/ValidatorList.h>
41 #include <ripple/app/misc/impl/AccountTxPaging.h>
42 #include <ripple/app/tx/apply.h>
43 #include <ripple/basics/base64.h>
44 #include <ripple/basics/mulDiv.h>
45 #include <ripple/basics/PerfLog.h>
46 #include <ripple/basics/safe_cast.h>
47 #include <ripple/basics/UptimeClock.h>
48 #include <ripple/core/ConfigSections.h>
49 #include <ripple/crypto/csprng.h>
50 #include <ripple/crypto/RFC1751.h>
51 #include <ripple/json/to_string.h>
52 #include <ripple/overlay/Cluster.h>
53 #include <ripple/overlay/Overlay.h>
54 #include <ripple/overlay/predicates.h>
55 #include <ripple/protocol/BuildInfo.h>
56 #include <ripple/resource/ResourceManager.h>
57 #include <ripple/rpc/DeliveredAmount.h>
58 #include <ripple/beast/rfc2616.h>
59 #include <ripple/beast/core/LexicalCast.h>
60 #include <ripple/beast/utility/rngfill.h>
61 #include <boost/asio/steady_timer.hpp>
62 #include <boost/asio/ip/host_name.hpp>
63 
64 #include <mutex>
65 #include <string>
66 #include <tuple>
67 #include <utility>
68 
69 namespace ripple {
70 
71 class NetworkOPsImp final
72  : public NetworkOPs
73 {
79  {
80  public:
82  bool const admin;
83  bool const local;
85  bool applied;
87 
90  bool a,
91  bool l,
92  FailHard f)
93  : transaction (t)
94  , admin (a)
95  , local (l)
96  , failType (f)
97  {
98  assert(local || failType == FailHard::no);
99  }
100  };
101 
105  enum class DispatchState : unsigned char
106  {
107  none,
108  scheduled,
109  running,
110  };
111 
113 
129  {
130  struct Counters
131  {
132  explicit Counters() = default;
133 
136  };
137 
141  std::chrono::system_clock::time_point start_ =
145  static Json::StaticString const dur_;
146 
147  public:
148  explicit StateAccounting ()
149  {
150  counters_[static_cast<std::size_t>(
151  OperatingMode::DISCONNECTED)].transitions = 1;
152  }
153 
160  void mode (OperatingMode om);
161 
168 
174  StateCountersJson json() const;
175 
176  struct CounterData {
177  decltype(counters_) counters;
178  decltype(mode_) mode;
179  decltype(start_) start;
180  };
181 
183  std::lock_guard lock(mutex_);
184  return { counters_, mode_, start_ };
185  }
186  };
187 
190  {
191  ServerFeeSummary() = default;
192 
194  TxQ::Metrics&& escalationMetrics,
195  LoadFeeTrack const & loadFeeTrack);
196  bool
197  operator !=(ServerFeeSummary const & b) const;
198 
199  bool
200  operator ==(ServerFeeSummary const & b) const
201  {
202  return !(*this != b);
203  }
204 
208  boost::optional<TxQ::Metrics> em = boost::none;
209  };
210 
211 
212 public:
214  bool standalone, std::size_t minPeerCount, bool start_valid,
215  JobQueue& job_queue, LedgerMaster& ledgerMaster, Stoppable& parent,
216  ValidatorKeys const & validatorKeys, boost::asio::io_service& io_svc,
217  beast::Journal journal, beast::insight::Collector::ptr const& collector)
218  : NetworkOPs (parent)
219  , app_ (app)
220  , m_clock (clock)
221  , m_journal (journal)
222  , m_localTX (make_LocalTxs ())
223  , mMode (start_valid ? OperatingMode::FULL :
225  , heartbeatTimer_ (io_svc)
226  , clusterTimer_ (io_svc)
227  , mConsensus (app,
228  make_FeeVote(setup_FeeVote (app_.config().section ("voting")),
229  app_.logs().journal("FeeVote")),
230  ledgerMaster,
231  *m_localTX,
232  app.getInboundTransactions(),
233  beast::get_abstract_clock<std::chrono::steady_clock>(),
234  validatorKeys,
235  app_.logs().journal("LedgerConsensus"))
237  , m_job_queue (job_queue)
238  , m_standalone (standalone)
239  , minPeerCount_ (start_valid ? 0 : minPeerCount)
240  , m_stats(std::bind (&NetworkOPsImp::collect_metrics, this),collector)
241  {
242  }
243 
244  ~NetworkOPsImp() override
245  {
246  // This clear() is necessary to ensure the shared_ptrs in this map get
247  // destroyed NOW because the objects in this map invoke methods on this
248  // class when they are destroyed
249  mRpcSubMap.clear();
250  }
251 
252 public:
253  OperatingMode getOperatingMode () const override
254  {
255  return mMode;
256  }
257 
259  OperatingMode const mode, bool const admin) const override;
260 
261  std::string strOperatingMode (bool const admin = false) const override
262  {
263  return strOperatingMode(mMode, admin);
264  }
265 
266  //
267  // Transaction operations.
268  //
269 
270  // Must complete immediately.
271  void submitTransaction (std::shared_ptr<STTx const> const&) override;
272 
273  void processTransaction (
274  std::shared_ptr<Transaction>& transaction,
275  bool bUnlimited, bool bLocal, FailHard failType) override;
276 
286  bool bUnlimited, FailHard failType);
287 
298  bool bUnlimited, FailHard failtype);
299 
303  void transactionBatch();
304 
310  void apply (std::unique_lock<std::mutex>& batchLock);
311 
312  //
313  // Owner functions.
314  //
315 
318  AccountID const& account) override;
319 
320  //
321  // Book functions.
322  //
323 
325  Book const&, AccountID const& uTakerID, const bool bProof,
326  unsigned int iLimit,
327  Json::Value const& jvMarker, Json::Value& jvResult)
328  override;
329 
330  // Ledger proposal/close functions.
332  RCLCxPeerPos proposal,
334 
335  bool recvValidation (
336  STValidation::ref val, std::string const& source) override;
337 
339  bool hasTXSet (
340  const std::shared_ptr<Peer>& peer, uint256 const& set,
341  protocol::TxSetStatus status);
342 
343  void mapComplete (
344  std::shared_ptr<SHAMap> const& map,
345  bool fromAcquire) override;
346 
347  // Network state machine.
348 
349  // Used for the "jump" case.
350 private:
352  std::shared_ptr<Ledger const> const& newLCL);
353  bool checkLastClosedLedger (
354  const Overlay::PeerSequence&, uint256& networkClosed);
355 
356 public:
357  bool beginConsensus (uint256 const& networkClosed) override;
358  void endConsensus () override;
359  void setStandAlone () override
360  {
362  }
363 
367  void setStateTimer () override;
368 
369  void setNeedNetworkLedger () override
370  {
371  needNetworkLedger_ = true;
372  }
373  void clearNeedNetworkLedger () override
374  {
375  needNetworkLedger_ = false;
376  }
377  bool isNeedNetworkLedger () override
378  {
379  return needNetworkLedger_;
380  }
381  bool isFull () override
382  {
384  }
385 
386  void setMode (OperatingMode om) override;
387 
388  bool isAmendmentBlocked () override
389  {
390  return amendmentBlocked_;
391  }
392  void setAmendmentBlocked () override;
393  bool
394  isAmendmentWarned() override
395  {
397  }
398  void
400  {
401  amendmentWarned_ = true;
402  }
403  void
405  {
406  amendmentWarned_ = false;
407  }
408  void consensusViewChange () override;
409 
410  Json::Value getConsensusInfo () override;
411  Json::Value getServerInfo (bool human, bool admin, bool counters) override;
412  void clearLedgerFetch () override;
413  Json::Value getLedgerFetchInfo () override;
415  boost::optional<std::chrono::milliseconds> consensusDelay) override;
416  uint256 getConsensusLCL () override;
417  void reportFeeChange () override;
419 
420  void updateLocalTx (ReadView const& view) override
421  {
422  m_localTX->sweep (view);
423  }
425  {
426  return m_localTX->size ();
427  }
428 
429  //Helper function to generate SQL query to get transactions.
431  std::string selection, AccountID const& account,
432  std::int32_t minLedger, std::int32_t maxLedger,
433  bool descending, std::uint32_t offset, int limit,
434  bool binary, bool count, bool bUnlimited);
435 
436  // Client information retrieval functions.
440  AccountID const& account,
441  std::int32_t minLedger, std::int32_t maxLedger, bool descending,
442  std::uint32_t offset, int limit, bool bUnlimited) override;
443 
444  AccountTxs
446  AccountID const& account,
447  std::int32_t minLedger,
448  std::int32_t maxLedger,
449  bool forward,
451  int limit,
452  bool bUnlimited) override;
453 
456 
459  AccountID const& account, std::int32_t minLedger,
460  std::int32_t maxLedger, bool descending, std::uint32_t offset,
461  int limit, bool bUnlimited) override;
462 
463 
466  AccountID const& account,
467  std::int32_t minLedger,
468  std::int32_t maxLedger,
469  bool forward,
471  int limit,
472  bool bUnlimited) override;
473 
474  //
475  // Monitoring: publisher side.
476  //
477  void pubLedger (
478  std::shared_ptr<ReadView const> const& lpAccepted) override;
480  std::shared_ptr<ReadView const> const& lpCurrent,
481  std::shared_ptr<STTx const> const& stTxn, TER terResult) override;
482  void pubValidation (
483  STValidation::ref val) override;
484 
485  //--------------------------------------------------------------------------
486  //
487  // InfoSub::Source.
488  //
489  void subAccount (
490  InfoSub::ref ispListener,
491  hash_set<AccountID> const& vnaAccountIDs, bool rt) override;
492  void unsubAccount (
493  InfoSub::ref ispListener,
494  hash_set<AccountID> const& vnaAccountIDs,
495  bool rt) override;
496 
497  // Just remove the subscription from the tracking
498  // not from the InfoSub. Needed for InfoSub destruction
499  void unsubAccountInternal (
500  std::uint64_t seq,
501  hash_set<AccountID> const& vnaAccountIDs,
502  bool rt) override;
503 
504  bool subLedger (InfoSub::ref ispListener, Json::Value& jvResult) override;
505  bool unsubLedger (std::uint64_t uListener) override;
506 
507  bool subServer (
508  InfoSub::ref ispListener, Json::Value& jvResult, bool admin) override;
509  bool unsubServer (std::uint64_t uListener) override;
510 
511  bool subBook (InfoSub::ref ispListener, Book const&) override;
512  bool unsubBook (std::uint64_t uListener, Book const&) override;
513 
514  bool subManifests (InfoSub::ref ispListener) override;
515  bool unsubManifests (std::uint64_t uListener) override;
516  void pubManifest (Manifest const&) override;
517 
518  bool subTransactions (InfoSub::ref ispListener) override;
519  bool unsubTransactions (std::uint64_t uListener) override;
520 
521  bool subRTTransactions (InfoSub::ref ispListener) override;
522  bool unsubRTTransactions (std::uint64_t uListener) override;
523 
524  bool subValidations (InfoSub::ref ispListener) override;
525  bool unsubValidations (std::uint64_t uListener) override;
526 
527  bool subPeerStatus (InfoSub::ref ispListener) override;
528  bool unsubPeerStatus (std::uint64_t uListener) override;
529  void pubPeerStatus (std::function<Json::Value(void)> const&) override;
530 
531  bool subConsensus (InfoSub::ref ispListener) override;
532  bool unsubConsensus (std::uint64_t uListener) override;
533 
534  InfoSub::pointer findRpcSub (std::string const& strUrl) override;
536  std::string const& strUrl, InfoSub::ref) override;
537  bool tryRemoveRpcSub (std::string const& strUrl) override;
538 
539  //--------------------------------------------------------------------------
540  //
541  // Stoppable.
542 
543  void onStop () override
544  {
546  {
547  boost::system::error_code ec;
548  heartbeatTimer_.cancel (ec);
549  if (ec)
550  {
551  JLOG (m_journal.error())
552  << "NetworkOPs: heartbeatTimer cancel error: "
553  << ec.message();
554  }
555 
556  ec.clear();
557  clusterTimer_.cancel (ec);
558  if (ec)
559  {
560  JLOG (m_journal.error())
561  << "NetworkOPs: clusterTimer cancel error: "
562  << ec.message();
563  }
564  }
565  // Make sure that any waitHandlers pending in our timers are done
566  // before we declare ourselves stopped.
567  using namespace std::chrono_literals;
568  waitHandlerCounter_.join("NetworkOPs", 1s, m_journal);
569  stopped ();
570  }
571 
572 private:
573  void setHeartbeatTimer ();
574  void setClusterTimer ();
575  void processHeartbeatTimer ();
576  void processClusterTimer ();
577 
579  const STTx& stTxn, TER terResult, bool bValidated,
580  std::shared_ptr<ReadView const> const& lpCurrent);
581 
583  std::shared_ptr<ReadView const> const& alAccepted,
584  const AcceptedLedgerTx& alTransaction);
585  void pubAccountTransaction (
586  std::shared_ptr<ReadView const> const& lpCurrent,
587  const AcceptedLedgerTx& alTransaction,
588  bool isAccepted);
589 
590  void pubServer ();
591  void pubConsensus (ConsensusPhase phase);
592 
593  std::string getHostId (bool forAdmin);
594 
595 private:
599 
603 
605 
607 
609 
613 
615  boost::asio::steady_timer heartbeatTimer_;
616  boost::asio::steady_timer clusterTimer_;
617 
619 
621 
624 
627 
629 
630  enum SubTypes
631  {
632  sLedger, // Accepted ledgers.
633  sManifests, // Received validator manifests.
634  sServer, // When server changes connectivity state.
635  sTransactions, // All accepted transactions.
636  sRTTransactions, // All proposed and accepted transactions.
637  sValidations, // Received validations.
638  sPeerStatus, // Peer status changes.
639  sConsensusPhase, // Consensus phase
640 
641  sLastEntry = sConsensusPhase // as this name implies, any new entry must
642  // be ADDED ABOVE this one
643  };
645 
647 
648 
650 
651  // Whether we are in standalone mode.
652  bool const m_standalone;
653 
654  // The number of nodes that we need to consider ourselves connected.
656 
657  // Transaction batching.
662 
664 
665 private:
666  struct Stats
667  {
668  template <class Handler>
669  Stats (Handler const& handler, beast::insight::Collector::ptr const& collector)
670  : hook (collector->make_hook (handler))
671  , disconnected_duration (collector->make_gauge("State_Accounting","Disconnected_duration"))
672  , connected_duration (collector->make_gauge("State_Accounting","Connected_duration"))
673  , syncing_duration(collector->make_gauge("State_Accounting", "Syncing_duration"))
674  , tracking_duration (collector->make_gauge("State_Accounting", "Tracking_duration"))
675  , full_duration (collector-> make_gauge("State_Accounting", "Full_duration"))
676  , disconnected_transitions (collector->make_gauge("State_Accounting","Disconnected_transitions"))
677  , connected_transitions (collector->make_gauge("State_Accounting","Connected_transitions"))
678  , syncing_transitions(collector->make_gauge("State_Accounting", "Syncing_transitions"))
679  , tracking_transitions (collector->make_gauge("State_Accounting", "Tracking_transitions"))
680  , full_transitions (collector-> make_gauge("State_Accounting", "Full_transitions"))
681  { }
682 
689 
695  };
696 
697  std::mutex m_statsMutex;//Mutex to lock m_stats
699 
700 private:
702  {
703  auto [counters, mode, start] = accounting_.getCounterData();
704  auto const current = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now() - start);
705  counters[static_cast<std::size_t>(mode)].dur += current;
706 
708  m_stats.disconnected_duration.set(counters[static_cast<std::size_t>(OperatingMode::DISCONNECTED)].dur.count());
709  m_stats.connected_duration.set(counters[static_cast<std::size_t>(OperatingMode::CONNECTED)].dur.count());
710  m_stats.syncing_duration.set(counters[static_cast<std::size_t>(OperatingMode::SYNCING)].dur.count());
711  m_stats.tracking_duration.set(counters[static_cast<std::size_t>(OperatingMode::TRACKING)].dur.count());
712  m_stats.full_duration.set(counters[static_cast<std::size_t>(OperatingMode::FULL)].dur.count());
713 
714  m_stats.disconnected_transitions.set(counters[static_cast<std::size_t>(OperatingMode::DISCONNECTED)].transitions);
715  m_stats.connected_transitions.set(counters[static_cast<std::size_t>(OperatingMode::CONNECTED)].transitions);
716  m_stats.syncing_transitions.set(counters[static_cast<std::size_t>(OperatingMode::SYNCING)].transitions);
717  m_stats.tracking_transitions.set(counters[static_cast<std::size_t>(OperatingMode::TRACKING)].transitions);
718  m_stats.full_transitions.set(counters[static_cast<std::size_t>(OperatingMode::FULL)].transitions);
719  }
720 };
721 
722 //------------------------------------------------------------------------------
723 
725  "disconnected",
726  "connected",
727  "syncing",
728  "tracking",
729  "full"}};
730 
732 
740 
741 //------------------------------------------------------------------------------
744 {
745  static std::string const hostname = boost::asio::ip::host_name();
746 
747  if (forAdmin)
748  return hostname;
749 
750  // For non-admin uses hash the node public key into a
751  // single RFC1751 word:
752  static std::string const shroudedHostId =
753  [this]()
754  {
755  auto const& id = app_.nodeIdentity();
756 
757  return RFC1751::getWordFromBlob (
758  id.first.data (),
759  id.first.size ());
760  }();
761 
762  return shroudedHostId;
763 }
764 
766 {
768  setClusterTimer ();
769 }
770 
772 {
773  // Only start the timer if waitHandlerCounter_ is not yet joined.
774  if (auto optionalCountedHandler = waitHandlerCounter_.wrap (
775  [this] (boost::system::error_code const& e)
776  {
777  if ((e.value() == boost::system::errc::success) &&
778  (! m_job_queue.isStopped()))
779  {
780  m_job_queue.addJob (jtNETOP_TIMER, "NetOPs.heartbeat",
781  [this] (Job&) { processHeartbeatTimer(); });
782  }
783  // Recover as best we can if an unexpected error occurs.
784  if (e.value() != boost::system::errc::success &&
785  e.value() != boost::asio::error::operation_aborted)
786  {
787  // Try again later and hope for the best.
788  JLOG (m_journal.error())
789  << "Heartbeat timer got error '" << e.message()
790  << "'. Restarting timer.";
791  setHeartbeatTimer();
792  }
793  }))
794  {
795  heartbeatTimer_.expires_from_now (
797  heartbeatTimer_.async_wait (std::move (*optionalCountedHandler));
798  }
799 }
800 
802 {
803  // Only start the timer if waitHandlerCounter_ is not yet joined.
804  if (auto optionalCountedHandler = waitHandlerCounter_.wrap (
805  [this] (boost::system::error_code const& e)
806  {
807  if ((e.value() == boost::system::errc::success) &&
808  (! m_job_queue.isStopped()))
809  {
810  m_job_queue.addJob (jtNETOP_CLUSTER, "NetOPs.cluster",
811  [this] (Job&) { processClusterTimer(); });
812  }
813  // Recover as best we can if an unexpected error occurs.
814  if (e.value() != boost::system::errc::success &&
815  e.value() != boost::asio::error::operation_aborted)
816  {
817  // Try again later and hope for the best.
818  JLOG (m_journal.error())
819  << "Cluster timer got error '" << e.message()
820  << "'. Restarting timer.";
821  setClusterTimer();
822  }
823  }))
824  {
825  using namespace std::chrono_literals;
826  clusterTimer_.expires_from_now (10s);
827  clusterTimer_.async_wait (std::move (*optionalCountedHandler));
828  }
829 }
830 
832 {
833  {
835 
836  // VFALCO NOTE This is for diagnosing a crash on exit
837  LoadManager& mgr (app_.getLoadManager ());
838  mgr.resetDeadlockDetector ();
839 
840  std::size_t const numPeers = app_.overlay ().size ();
841 
842  // do we have sufficient peers? If not, we are disconnected.
843  if (numPeers < minPeerCount_)
844  {
846  {
848  JLOG(m_journal.warn())
849  << "Node count (" << numPeers << ") has fallen "
850  << "below required minimum (" << minPeerCount_ << ").";
851  }
852 
853  // MasterMutex lock need not be held to call setHeartbeatTimer()
854  lock.unlock();
855  // We do not call mConsensus.timerEntry until there are enough
856  // peers providing meaningful inputs to consensus
858  return;
859  }
860 
862  {
864  JLOG(m_journal.info())
865  << "Node count (" << numPeers << ") is sufficient.";
866  }
867 
868  // Check if the last validated ledger forces a change between these
869  // states.
872  else if (mMode == OperatingMode::CONNECTED)
874  }
875 
877 
878  const ConsensusPhase currPhase = mConsensus.phase();
879  if (mLastConsensusPhase != currPhase)
880  {
881  reportConsensusStateChange(currPhase);
882  mLastConsensusPhase = currPhase;
883  }
884 
886 }
887 
889 {
890  using namespace std::chrono_literals;
891  bool const update = app_.cluster().update(
892  app_.nodeIdentity().first,
893  "",
896  : 0,
897  app_.timeKeeper().now());
898 
899  if (!update)
900  {
901  JLOG(m_journal.debug()) << "Too soon to send cluster update";
902  setClusterTimer ();
903  return;
904  }
905 
906  protocol::TMCluster cluster;
908  [&cluster](ClusterNode const& node)
909  {
910  protocol::TMClusterNode& n = *cluster.add_clusternodes();
911  n.set_publickey(toBase58 (
913  node.identity()));
914  n.set_reporttime(
915  node.getReportTime().time_since_epoch().count());
916  n.set_nodeload(node.getLoadFee());
917  if (!node.name().empty())
918  n.set_nodename(node.name());
919  });
920 
922  for (auto& item: gossip.items)
923  {
924  protocol::TMLoadSource& node = *cluster.add_loadsources();
925  node.set_name (to_string (item.address));
926  node.set_cost (item.balance);
927  }
929  std::make_shared<Message>(cluster, protocol::mtCLUSTER),
930  peer_in_cluster ()));
931  setClusterTimer ();
932 }
933 
934 //------------------------------------------------------------------------------
935 
937  bool const admin) const
938 {
939  if (mode == OperatingMode::FULL && admin)
940  {
941  auto const consensusMode = mConsensus.mode();
942  if (consensusMode != ConsensusMode::wrongLedger)
943  {
944  if (consensusMode == ConsensusMode::proposing)
945  return "proposing";
946 
947  if (mConsensus.validating())
948  return "validating";
949  }
950  }
951 
952  return states_[static_cast<std::size_t>(mode)];
953 }
954 
956 {
957  if (isNeedNetworkLedger ())
958  {
959  // Nothing we can do if we've never been in sync
960  return;
961  }
962 
963  // this is an asynchronous interface
964  auto const trans = sterilize(*iTrans);
965 
966  auto const txid = trans->getTransactionID ();
967  auto const flags = app_.getHashRouter().getFlags(txid);
968 
969  if ((flags & SF_BAD) != 0)
970  {
971  JLOG(m_journal.warn()) << "Submitted transaction cached bad";
972  return;
973  }
974 
975  try
976  {
977  auto const [validity, reason] = checkValidity(
978  app_.getHashRouter(), *trans,
980  app_.config());
981 
982  if (validity != Validity::Valid)
983  {
984  JLOG(m_journal.warn()) <<
985  "Submitted transaction invalid: " <<
986  reason;
987  return;
988  }
989  }
990  catch (std::exception const&)
991  {
992  JLOG(m_journal.warn()) << "Exception checking transaction" << txid;
993 
994  return;
995  }
996 
997  std::string reason;
998 
999  auto tx = std::make_shared<Transaction> (
1000  trans, reason, app_);
1001 
1003  jtTRANSACTION, "submitTxn",
1004  [this, tx] (Job&) {
1005  auto t = tx;
1006  processTransaction(t, false, false, FailHard::no);
1007  });
1008 }
1009 
1011  bool bUnlimited, bool bLocal, FailHard failType)
1012 {
1013  auto ev = m_job_queue.makeLoadEvent (jtTXN_PROC, "ProcessTXN");
1014  auto const newFlags = app_.getHashRouter ().getFlags (transaction->getID ());
1015 
1016  if ((newFlags & SF_BAD) != 0)
1017  {
1018  // cached bad
1019  transaction->setStatus (INVALID);
1020  transaction->setResult (temBAD_SIGNATURE);
1021  return;
1022  }
1023 
1024  // NOTE eahennis - I think this check is redundant,
1025  // but I'm not 100% sure yet.
1026  // If so, only cost is looking up HashRouter flags.
1027  auto const view = m_ledgerMaster.getCurrentLedger();
1028  auto const [validity, reason] = checkValidity(
1029  app_.getHashRouter(),
1030  *transaction->getSTransaction(),
1031  view->rules(), app_.config());
1032  assert(validity == Validity::Valid);
1033 
1034  // Not concerned with local checks at this point.
1035  if (validity == Validity::SigBad)
1036  {
1037  JLOG(m_journal.info()) << "Transaction has bad signature: " <<
1038  reason;
1039  transaction->setStatus(INVALID);
1040  transaction->setResult(temBAD_SIGNATURE);
1041  app_.getHashRouter().setFlags(transaction->getID(),
1042  SF_BAD);
1043  return;
1044  }
1045 
1046  // canonicalize can change our pointer
1047  app_.getMasterTransaction ().canonicalize (&transaction);
1048 
1049  if (bLocal)
1050  doTransactionSync (transaction, bUnlimited, failType);
1051  else
1052  doTransactionAsync (transaction, bUnlimited, failType);
1053 }
1054 
1056  bool bUnlimited, FailHard failType)
1057 {
1058  std::lock_guard lock (mMutex);
1059 
1060  if (transaction->getApplying())
1061  return;
1062 
1063  mTransactions.push_back (TransactionStatus (transaction, bUnlimited, false,
1064  failType));
1065  transaction->setApplying();
1066 
1068  {
1069  if (m_job_queue.addJob (
1070  jtBATCH, "transactionBatch",
1071  [this] (Job&) { transactionBatch(); }))
1072  {
1074  }
1075  }
1076 }
1077 
1079  bool bUnlimited, FailHard failType)
1080 {
1082 
1083  if (! transaction->getApplying())
1084  {
1085  mTransactions.push_back (TransactionStatus (transaction, bUnlimited,
1086  true, failType));
1087  transaction->setApplying();
1088  }
1089 
1090  do
1091  {
1093  {
1094  // A batch processing job is already running, so wait.
1095  mCond.wait (lock);
1096  }
1097  else
1098  {
1099  apply (lock);
1100 
1101  if (mTransactions.size())
1102  {
1103  // More transactions need to be applied, but by another job.
1104  if (m_job_queue.addJob (
1105  jtBATCH, "transactionBatch",
1106  [this] (Job&) { transactionBatch(); }))
1107  {
1109  }
1110  }
1111  }
1112  }
1113  while (transaction->getApplying());
1114 }
1115 
1117 {
1119 
1121  return;
1122 
1123  while (mTransactions.size())
1124  {
1125  apply (lock);
1126  }
1127 }
1128 
1130 {
1131  std::vector<TransactionStatus> submit_held;
1132  std::vector<TransactionStatus> transactions;
1133  mTransactions.swap (transactions);
1134  assert (! transactions.empty());
1135 
1138 
1139  batchLock.unlock();
1140 
1141  {
1142  std::unique_lock masterLock{app_.getMasterMutex(), std::defer_lock};
1143  bool changed = false;
1144  {
1145  std::unique_lock ledgerLock{m_ledgerMaster.peekMutex(), std::defer_lock};
1146  std::lock(masterLock, ledgerLock);
1147 
1149  [&](OpenView& view, beast::Journal j)
1150  {
1151  for (TransactionStatus& e : transactions)
1152  {
1153  // we check before adding to the batch
1154  ApplyFlags flags = tapNONE;
1155  if (e.admin)
1156  flags |= tapUNLIMITED;
1157 
1158  if (e.failType == FailHard::yes)
1159  flags |= tapFAIL_HARD;
1160 
1161  auto const result = app_.getTxQ().apply(
1162  app_, view, e.transaction->getSTransaction(),
1163  flags, j);
1164  e.result = result.first;
1165  e.applied = result.second;
1166  changed = changed || result.second;
1167  }
1168  return changed;
1169  });
1170  }
1171  if (changed)
1172  reportFeeChange();
1173 
1174  boost::optional<LedgerIndex> validatedLedgerIndex;
1175  if (auto const l = m_ledgerMaster.getValidatedLedger())
1176  validatedLedgerIndex = l->info().seq;
1177 
1178  auto newOL = app_.openLedger().current();
1179  for (TransactionStatus& e : transactions)
1180  {
1181  e.transaction->clearSubmitResult();
1182 
1183  if (e.applied)
1184  {
1185  pubProposedTransaction (newOL,
1186  e.transaction->getSTransaction(), e.result);
1187  e.transaction->setApplied();
1188  }
1189 
1190  e.transaction->setResult (e.result);
1191 
1192  if (isTemMalformed (e.result))
1193  app_.getHashRouter().setFlags (e.transaction->getID(), SF_BAD);
1194 
1195  #ifdef DEBUG
1196  if (e.result != tesSUCCESS)
1197  {
1198  std::string token, human;
1199 
1200  if (transResultInfo (e.result, token, human))
1201  {
1202  JLOG(m_journal.info()) << "TransactionResult: "
1203  << token << ": " << human;
1204  }
1205  }
1206  #endif
1207 
1208  bool addLocal = e.local;
1209 
1210  if (e.result == tesSUCCESS)
1211  {
1212  JLOG(m_journal.debug())
1213  << "Transaction is now included in open ledger";
1214  e.transaction->setStatus (INCLUDED);
1215 
1216  auto txCur = e.transaction->getSTransaction();
1217  for (auto const& tx : m_ledgerMaster.pruneHeldTransactions(
1218  txCur->getAccountID(sfAccount), txCur->getSequence() + 1))
1219  {
1220  std::string reason;
1221  auto const trans = sterilize(*tx);
1222  auto t = std::make_shared<Transaction>(
1223  trans, reason, app_);
1224  submit_held.emplace_back(
1225  t, false, false, FailHard::no);
1226  t->setApplying();
1227  }
1228  }
1229  else if (e.result == tefPAST_SEQ)
1230  {
1231  // duplicate or conflict
1232  JLOG(m_journal.info()) << "Transaction is obsolete";
1233  e.transaction->setStatus (OBSOLETE);
1234  }
1235  else if (e.result == terQUEUED)
1236  {
1237  JLOG(m_journal.debug()) << "Transaction is likely to claim a"
1238  << " fee, but is queued until fee drops";
1239 
1240  e.transaction->setStatus(HELD);
1241  // Add to held transactions, because it could get
1242  // kicked out of the queue, and this will try to
1243  // put it back.
1244  m_ledgerMaster.addHeldTransaction(e.transaction);
1245  e.transaction->setQueued();
1246  e.transaction->setKept();
1247  }
1248  else if (isTerRetry (e.result))
1249  {
1250  if (e.failType != FailHard::yes)
1251  {
1252  // transaction should be held
1253  JLOG(m_journal.debug())
1254  << "Transaction should be held: " << e.result;
1255  e.transaction->setStatus (HELD);
1256  m_ledgerMaster.addHeldTransaction (e.transaction);
1257  e.transaction->setKept();
1258  }
1259  }
1260  else
1261  {
1262  JLOG(m_journal.debug())
1263  << "Status other than success " << e.result;
1264  e.transaction->setStatus (INVALID);
1265  }
1266 
1267  auto const enforceFailHard = e.failType == FailHard::yes &&
1268  !isTesSuccess(e.result);
1269 
1270  if (addLocal && !enforceFailHard)
1271  {
1272  m_localTX->push_back (
1274  e.transaction->getSTransaction());
1275  e.transaction->setKept();
1276  }
1277 
1278  if ((e.applied || ((mMode != OperatingMode::FULL) &&
1279  (e.failType != FailHard::yes) && e.local) ||
1280  (e.result == terQUEUED)) && !enforceFailHard)
1281  {
1282  auto const toSkip = app_.getHashRouter().shouldRelay(
1283  e.transaction->getID());
1284 
1285  if (toSkip)
1286  {
1287  protocol::TMTransaction tx;
1288  Serializer s;
1289 
1290  e.transaction->getSTransaction()->add (s);
1291  tx.set_rawtransaction (s.data(), s.size());
1292  tx.set_status (protocol::tsCURRENT);
1293  tx.set_receivetimestamp (app_.timeKeeper().now().time_since_epoch().count());
1294  tx.set_deferred(e.result == terQUEUED);
1295  // FIXME: This should be when we received it
1297  std::make_shared<Message> (tx, protocol::mtTRANSACTION),
1298  peer_in_set(*toSkip)));
1299  e.transaction->setBroadcast();
1300  }
1301  }
1302 
1303  if (validatedLedgerIndex)
1304  {
1305  auto [fee, accountSeq, availableSeq] =
1307  *newOL, e.transaction->getSTransaction());
1308  e.transaction->setCurrentLedgerState(
1309  *validatedLedgerIndex, fee, accountSeq, availableSeq);
1310  }
1311  }
1312  }
1313 
1314  batchLock.lock();
1315 
1316  for (TransactionStatus& e : transactions)
1317  e.transaction->clearApplying();
1318 
1319  if (! submit_held.empty())
1320  {
1321  if (mTransactions.empty())
1322  mTransactions.swap(submit_held);
1323  else
1324  for (auto& e : submit_held)
1325  mTransactions.push_back(std::move(e));
1326  }
1327 
1328  mCond.notify_all();
1329 
1331 }
1332 
1333 //
1334 // Owner functions
1335 //
1336 
1338  std::shared_ptr<ReadView const> lpLedger, AccountID const& account)
1339 {
1340  Json::Value jvObjects (Json::objectValue);
1341  auto uRootIndex = getOwnerDirIndex (account);
1342  auto sleNode = lpLedger->read (keylet::page (uRootIndex));
1343  if (sleNode)
1344  {
1345  std::uint64_t uNodeDir;
1346 
1347  do
1348  {
1349  for (auto const& uDirEntry : sleNode->getFieldV256 (sfIndexes))
1350  {
1351  auto sleCur = lpLedger->read (keylet::child (uDirEntry));
1352  assert (sleCur);
1353 
1354  switch (sleCur->getType ())
1355  {
1356  case ltOFFER:
1357  if (!jvObjects.isMember (jss::offers))
1358  jvObjects[jss::offers] = Json::Value (Json::arrayValue);
1359 
1360  jvObjects[jss::offers].append (
1361  sleCur->getJson (JsonOptions::none));
1362  break;
1363 
1364  case ltRIPPLE_STATE:
1365  if (!jvObjects.isMember (jss::ripple_lines))
1366  {
1367  jvObjects[jss::ripple_lines] =
1369  }
1370 
1371  jvObjects[jss::ripple_lines].append (
1372  sleCur->getJson (JsonOptions::none));
1373  break;
1374 
1375  case ltACCOUNT_ROOT:
1376  case ltDIR_NODE:
1377  default:
1378  assert (false);
1379  break;
1380  }
1381  }
1382 
1383  uNodeDir = sleNode->getFieldU64 (sfIndexNext);
1384 
1385  if (uNodeDir)
1386  {
1387  sleNode = lpLedger->read (keylet::page (uRootIndex, uNodeDir));
1388  assert (sleNode);
1389  }
1390  }
1391  while (uNodeDir);
1392  }
1393 
1394  return jvObjects;
1395 }
1396 
1397 //
1398 // Other
1399 //
1400 
1402 {
1403  amendmentBlocked_ = true;
1405 }
1406 
1408  const Overlay::PeerSequence& peerList, uint256& networkClosed)
1409 {
1410  // Returns true if there's an *abnormal* ledger issue, normal changing in
1411  // TRACKING mode should return false. Do we have sufficient validations for
1412  // our last closed ledger? Or do sufficient nodes agree? And do we have no
1413  // better ledger available? If so, we are either tracking or full.
1414 
1415  JLOG(m_journal.trace()) << "NetworkOPsImp::checkLastClosedLedger";
1416 
1417  auto const ourClosed = m_ledgerMaster.getClosedLedger ();
1418 
1419  if (!ourClosed)
1420  return false;
1421 
1422  uint256 closedLedger = ourClosed->info().hash;
1423  uint256 prevClosedLedger = ourClosed->info().parentHash;
1424  JLOG(m_journal.trace()) << "OurClosed: " << closedLedger;
1425  JLOG(m_journal.trace()) << "PrevClosed: " << prevClosedLedger;
1426 
1427  //-------------------------------------------------------------------------
1428  // Determine preferred last closed ledger
1429 
1430  auto & validations = app_.getValidations();
1431  JLOG(m_journal.debug())
1432  << "ValidationTrie " << Json::Compact(validations.getJsonTrie());
1433 
1434  // Will rely on peer LCL if no trusted validations exist
1436  peerCounts[closedLedger] = 0;
1438  peerCounts[closedLedger]++;
1439 
1440  for (auto& peer : peerList)
1441  {
1442  uint256 peerLedger = peer->getClosedLedgerHash();
1443 
1444  if (peerLedger.isNonZero())
1445  ++peerCounts[peerLedger];
1446  }
1447 
1448  for(auto const & it: peerCounts)
1449  JLOG(m_journal.debug()) << "L: " << it.first << " n=" << it.second;
1450 
1451  uint256 preferredLCL = validations.getPreferredLCL(
1452  RCLValidatedLedger{ourClosed, validations.adaptor().journal()},
1454  peerCounts);
1455 
1456  bool switchLedgers = preferredLCL != closedLedger;
1457  if(switchLedgers)
1458  closedLedger = preferredLCL;
1459  //-------------------------------------------------------------------------
1460  if (switchLedgers && (closedLedger == prevClosedLedger))
1461  {
1462  // don't switch to our own previous ledger
1463  JLOG(m_journal.info()) << "We won't switch to our own previous ledger";
1464  networkClosed = ourClosed->info().hash;
1465  switchLedgers = false;
1466  }
1467  else
1468  networkClosed = closedLedger;
1469 
1470  if (!switchLedgers)
1471  return false;
1472 
1473  auto consensus = m_ledgerMaster.getLedgerByHash(closedLedger);
1474 
1475  if (!consensus)
1476  consensus = app_.getInboundLedgers().acquire(
1477  closedLedger, 0, InboundLedger::Reason::CONSENSUS);
1478 
1479  if (consensus &&
1480  (!m_ledgerMaster.canBeCurrent (consensus) ||
1482  *consensus, m_journal.debug(), "Not switching")))
1483  {
1484  // Don't switch to a ledger not on the validated chain
1485  // or with an invalid close time or sequence
1486  networkClosed = ourClosed->info().hash;
1487  return false;
1488  }
1489 
1490  JLOG(m_journal.warn()) << "We are not running on the consensus ledger";
1491  JLOG(m_journal.info()) << "Our LCL: " << getJson(*ourClosed);
1492  JLOG(m_journal.info()) << "Net LCL " << closedLedger;
1493 
1495  || (mMode == OperatingMode::FULL))
1496  {
1498  }
1499 
1500  if (consensus)
1501  {
1502  // FIXME: If this rewinds the ledger sequence, or has the same
1503  // sequence, we should update the status on any stored transactions
1504  // in the invalidated ledgers.
1505  switchLastClosedLedger(consensus);
1506  }
1507 
1508  return true;
1509 }
1510 
1512  std::shared_ptr<Ledger const> const& newLCL)
1513 {
1514  // set the newLCL as our last closed ledger -- this is abnormal code
1515  JLOG(m_journal.error()) <<
1516  "JUMP last closed ledger to " << newLCL->info().hash;
1517 
1519 
1520  // Update fee computations.
1521  app_.getTxQ().processClosedLedger(app_, *newLCL, true);
1522 
1523  // Caller must own master lock
1524  {
1525  // Apply tx in old open ledger to new
1526  // open ledger. Then apply local tx.
1527 
1528  auto retries = m_localTX->getTxSet();
1529  auto const lastVal =
1531  boost::optional<Rules> rules;
1532  if (lastVal)
1533  rules.emplace(*lastVal, app_.config().features);
1534  else
1535  rules.emplace(app_.config().features);
1536  app_.openLedger().accept(app_, *rules,
1537  newLCL, OrderedTxs({}), false, retries,
1538  tapNONE, "jump",
1539  [&](OpenView& view, beast::Journal j)
1540  {
1541  // Stuff the ledger with transactions from the queue.
1542  return app_.getTxQ().accept(app_, view);
1543  });
1544  }
1545 
1546  m_ledgerMaster.switchLCL (newLCL);
1547 
1548  protocol::TMStatusChange s;
1549  s.set_newevent (protocol::neSWITCHED_LEDGER);
1550  s.set_ledgerseq (newLCL->info().seq);
1551  s.set_networktime (app_.timeKeeper().now().time_since_epoch().count());
1552  s.set_ledgerhashprevious (
1553  newLCL->info().parentHash.begin (),
1554  newLCL->info().parentHash.size ());
1555  s.set_ledgerhash (
1556  newLCL->info().hash.begin (),
1557  newLCL->info().hash.size ());
1558 
1560  std::make_shared<Message> (s, protocol::mtSTATUS_CHANGE)));
1561 }
1562 
1563 bool NetworkOPsImp::beginConsensus (uint256 const& networkClosed)
1564 {
1565  assert (networkClosed.isNonZero ());
1566 
1567  auto closingInfo = m_ledgerMaster.getCurrentLedger()->info();
1568 
1569  JLOG(m_journal.info()) <<
1570  "Consensus time for #" << closingInfo.seq <<
1571  " with LCL " << closingInfo.parentHash;
1572 
1573  auto prevLedger = m_ledgerMaster.getLedgerByHash(
1574  closingInfo.parentHash);
1575 
1576  if(! prevLedger)
1577  {
1578  // this shouldn't happen unless we jump ledgers
1579  if (mMode == OperatingMode::FULL)
1580  {
1581  JLOG(m_journal.warn()) << "Don't have LCL, going to tracking";
1583  }
1584 
1585  return false;
1586  }
1587 
1588  assert (prevLedger->info().hash == closingInfo.parentHash);
1589  assert (closingInfo.parentHash ==
1590  m_ledgerMaster.getClosedLedger()->info().hash);
1591 
1592  TrustChanges const changes = app_.validators().updateTrusted(
1594 
1595  if (!changes.added.empty() || !changes.removed.empty())
1596  app_.getValidations().trustChanged(changes.added, changes.removed);
1597 
1600  networkClosed,
1601  prevLedger,
1602  changes.removed);
1603 
1604  const ConsensusPhase currPhase = mConsensus.phase();
1605  if (mLastConsensusPhase != currPhase)
1606  {
1607  reportConsensusStateChange(currPhase);
1608  mLastConsensusPhase = currPhase;
1609  }
1610 
1611  JLOG(m_journal.debug()) << "Initiating consensus engine";
1612  return true;
1613 }
1614 
1616 {
1617  return mConsensus.prevLedgerID ();
1618 }
1619 
1621  RCLCxPeerPos peerPos,
1623 {
1625  app_.timeKeeper().closeTime(), peerPos))
1626  {
1627  app_.overlay().relay(*set, peerPos.suppressionID());
1628  }
1629  else
1630  JLOG(m_journal.info()) << "Not relaying trusted proposal";
1631 }
1632 
1633 void
1635  std::shared_ptr<SHAMap> const& map, bool fromAcquire)
1636 {
1637  // We now have an additional transaction set
1638  // either created locally during the consensus process
1639  // or acquired from a peer
1640 
1641  // Inform peers we have this set
1642  protocol::TMHaveTransactionSet msg;
1643  msg.set_hash (map->getHash().as_uint256().begin(), 256 / 8);
1644  msg.set_status (protocol::tsHAVE);
1646  std::make_shared<Message> (
1647  msg, protocol::mtHAVE_SET)));
1648 
1649  // We acquired it because consensus asked us to
1650  if (fromAcquire)
1653  RCLTxSet{map});
1654 }
1655 
1657 {
1658  uint256 deadLedger = m_ledgerMaster.getClosedLedger ()->info().parentHash;
1659 
1660  for (auto const& it : app_.overlay ().getActivePeers ())
1661  {
1662  if (it && (it->getClosedLedgerHash () == deadLedger))
1663  {
1664  JLOG(m_journal.trace()) << "Killing obsolete peer status";
1665  it->cycleStatus ();
1666  }
1667  }
1668 
1669  uint256 networkClosed;
1670  bool ledgerChange = checkLastClosedLedger (
1671  app_.overlay ().getActivePeers (), networkClosed);
1672 
1673  if (networkClosed.isZero ())
1674  return;
1675 
1676  // WRITEME: Unless we are in FULL and in the process of doing a consensus,
1677  // we must count how many nodes share our LCL, how many nodes disagree with
1678  // our LCL, and how many validations our LCL has. We also want to check
1679  // timing to make sure there shouldn't be a newer LCL. We need this
1680  // information to do the next three tests.
1681 
1683  || (mMode == OperatingMode::SYNCING)) && !ledgerChange)
1684  {
1685  // Count number of peers that agree with us and UNL nodes whose
1686  // validations we have for LCL. If the ledger is good enough, go to
1687  // TRACKING - TODO
1688  if (!needNetworkLedger_)
1690  }
1691 
1693  || (mMode == OperatingMode::TRACKING)) && !ledgerChange)
1694  {
1695  // check if the ledger is good enough to go to FULL
1696  // Note: Do not go to FULL if we don't have the previous ledger
1697  // check if the ledger is bad enough to go to CONNECTE D -- TODO
1699  if (app_.timeKeeper().now() <
1700  (current->info().parentCloseTime + 2* current->info().closeTimeResolution))
1701  {
1703  }
1704  }
1705 
1706  beginConsensus (networkClosed);
1707 }
1708 
1710 {
1711  if ((mMode == OperatingMode::FULL)
1713  {
1715  }
1716 }
1717 
1719 {
1720  // VFALCO consider std::shared_mutex
1722 
1723  if (!mStreamMaps[sManifests].empty ())
1724  {
1726 
1727  jvObj [jss::type] = "manifestReceived";
1728  jvObj [jss::master_key] = toBase58(
1730  if (!mo.signingKey.empty())
1731  jvObj[jss::signing_key] =
1733  jvObj [jss::seq] = Json::UInt (mo.sequence);
1734  if (auto sig = mo.getSignature())
1735  jvObj [jss::signature] = strHex (*sig);
1736  jvObj [jss::master_signature] = strHex (mo.getMasterSignature ());
1737 
1738  for (auto i = mStreamMaps[sManifests].begin ();
1739  i != mStreamMaps[sManifests].end (); )
1740  {
1741  if (auto p = i->second.lock())
1742  {
1743  p->send (jvObj, true);
1744  ++i;
1745  }
1746  else
1747  {
1748  i = mStreamMaps[sManifests].erase (i);
1749  }
1750  }
1751  }
1752 }
1753 
1755  XRPAmount fee,
1756  TxQ::Metrics&& escalationMetrics,
1757  LoadFeeTrack const & loadFeeTrack)
1758  : loadFactorServer{loadFeeTrack.getLoadFactor()}
1759  , loadBaseServer{loadFeeTrack.getLoadBase()}
1760  , baseFee{fee}
1761  , em{std::move(escalationMetrics)}
1762 {
1763 
1764 }
1765 
1766 
1767 bool
1769 {
1770  if(loadFactorServer != b.loadFactorServer ||
1771  loadBaseServer != b.loadBaseServer ||
1772  baseFee != b.baseFee ||
1773  em.is_initialized() != b.em.is_initialized())
1774  return true;
1775 
1776  if(em && b.em)
1777  {
1778  return (em->minProcessingFeeLevel != b.em->minProcessingFeeLevel ||
1779  em->openLedgerFeeLevel != b.em->openLedgerFeeLevel ||
1780  em->referenceFeeLevel != b.em->referenceFeeLevel);
1781  }
1782 
1783  return false;
1784 }
1785 
1786 // Need to cap to uint64 to uint32 due to JSON limitations
1788 {
1789  constexpr std::uint64_t max32 =
1791 
1792  return std::min(max32, v);
1793 };
1794 
1796 {
1797  // VFALCO TODO Don't hold the lock across calls to send...make a copy of the
1798  // list into a local array while holding the lock then release the
1799  // lock and call send on everyone.
1800  //
1802 
1803  if (!mStreamMaps[sServer].empty ())
1804  {
1806 
1807  ServerFeeSummary f{app_.openLedger().current()->fees().base,
1809  app_.getFeeTrack()};
1810 
1811  jvObj [jss::type] = "serverStatus";
1812  jvObj [jss::server_status] = strOperatingMode ();
1813  jvObj [jss::load_base] = f.loadBaseServer;
1814  jvObj [jss::load_factor_server] = f.loadFactorServer;
1815  jvObj [jss::base_fee] = f.baseFee.jsonClipped();
1816 
1817  if(f.em)
1818  {
1819  auto const loadFactor =
1820  std::max(safe_cast<std::uint64_t>(f.loadFactorServer),
1821  mulDiv(f.em->openLedgerFeeLevel, f.loadBaseServer,
1822  f.em->referenceFeeLevel).second);
1823 
1824  jvObj [jss::load_factor] = trunc32(loadFactor);
1825  jvObj [jss::load_factor_fee_escalation] =
1826  f.em->openLedgerFeeLevel.jsonClipped();
1827  jvObj [jss::load_factor_fee_queue] =
1828  f.em->minProcessingFeeLevel.jsonClipped();
1829  jvObj [jss::load_factor_fee_reference] =
1830  f.em->referenceFeeLevel.jsonClipped();
1831 
1832  }
1833  else
1834  jvObj [jss::load_factor] = f.loadFactorServer;
1835 
1836  mLastFeeSummary = f;
1837 
1838  for (auto i = mStreamMaps[sServer].begin ();
1839  i != mStreamMaps[sServer].end (); )
1840  {
1841  InfoSub::pointer p = i->second.lock ();
1842 
1843  // VFALCO TODO research the possibility of using thread queues and
1844  // linearizing the deletion of subscribers with the
1845  // sending of JSON data.
1846  if (p)
1847  {
1848  p->send (jvObj, true);
1849  ++i;
1850  }
1851  else
1852  {
1853  i = mStreamMaps[sServer].erase (i);
1854  }
1855  }
1856  }
1857 }
1858 
1860 {
1862 
1863  auto& streamMap = mStreamMaps[sConsensusPhase];
1864  if (!streamMap.empty ())
1865  {
1867  jvObj [jss::type] = "consensusPhase";
1868  jvObj [jss::consensus] = to_string(phase);
1869 
1870  for (auto i = streamMap.begin ();
1871  i != streamMap.end (); )
1872  {
1873  if (auto p = i->second.lock())
1874  {
1875  p->send (jvObj, true);
1876  ++i;
1877  }
1878  else
1879  {
1880  i = streamMap.erase (i);
1881  }
1882  }
1883  }
1884 }
1885 
1886 
1888 {
1889  // VFALCO consider std::shared_mutex
1891 
1892  if (!mStreamMaps[sValidations].empty ())
1893  {
1895 
1896  auto const signerPublic = val->getSignerPublic();
1897 
1898  jvObj [jss::type] = "validationReceived";
1899  jvObj [jss::validation_public_key] = toBase58(
1901  signerPublic);
1902  jvObj [jss::ledger_hash] = to_string (val->getLedgerHash ());
1903  jvObj [jss::signature] = strHex (val->getSignature ());
1904  jvObj [jss::full] = val->isFull();
1905  jvObj [jss::flags] = val->getFlags();
1906  jvObj [jss::signing_time] = *(*val)[~sfSigningTime];
1907 
1908  auto const masterKey = app_.validatorManifests().getMasterKey(signerPublic);
1909 
1910  if(masterKey != signerPublic)
1911  jvObj [jss::master_key] = toBase58(TokenType::NodePublic, masterKey);
1912 
1913  if (auto const seq = (*val)[~sfLedgerSequence])
1914  jvObj [jss::ledger_index] = to_string (*seq);
1915 
1916  if (val->isFieldPresent (sfAmendments))
1917  {
1918  jvObj[jss::amendments] = Json::Value (Json::arrayValue);
1919  for (auto const& amendment : val->getFieldV256(sfAmendments))
1920  jvObj [jss::amendments].append (to_string (amendment));
1921  }
1922 
1923  if (auto const closeTime = (*val)[~sfCloseTime])
1924  jvObj [jss::close_time] = *closeTime;
1925 
1926  if (auto const loadFee = (*val)[~sfLoadFee])
1927  jvObj [jss::load_fee] = *loadFee;
1928 
1929  if (auto const baseFee = (*val)[~sfBaseFee])
1930  jvObj [jss::base_fee] = static_cast<double> (*baseFee);
1931 
1932  if (auto const reserveBase = (*val)[~sfReserveBase])
1933  jvObj [jss::reserve_base] = *reserveBase;
1934 
1935  if (auto const reserveInc = (*val)[~sfReserveIncrement])
1936  jvObj [jss::reserve_inc] = *reserveInc;
1937 
1938  for (auto i = mStreamMaps[sValidations].begin ();
1939  i != mStreamMaps[sValidations].end (); )
1940  {
1941  if (auto p = i->second.lock())
1942  {
1943  p->send (jvObj, true);
1944  ++i;
1945  }
1946  else
1947  {
1948  i = mStreamMaps[sValidations].erase (i);
1949  }
1950  }
1951  }
1952 }
1953 
1955  std::function<Json::Value(void)> const& func)
1956 {
1958 
1959  if (!mStreamMaps[sPeerStatus].empty ())
1960  {
1961  Json::Value jvObj (func());
1962 
1963  jvObj [jss::type] = "peerStatusChange";
1964 
1965  for (auto i = mStreamMaps[sPeerStatus].begin ();
1966  i != mStreamMaps[sPeerStatus].end (); )
1967  {
1968  InfoSub::pointer p = i->second.lock ();
1969 
1970  if (p)
1971  {
1972  p->send (jvObj, true);
1973  ++i;
1974  }
1975  else
1976  {
1977  i = mStreamMaps[sPeerStatus].erase (i);
1978  }
1979  }
1980  }
1981 }
1982 
1984 {
1985  using namespace std::chrono_literals;
1986  if (om == OperatingMode::CONNECTED)
1987  {
1988  if (app_.getLedgerMaster ().getValidatedLedgerAge () < 1min)
1990  }
1991  else if (om == OperatingMode::SYNCING)
1992  {
1993  if (app_.getLedgerMaster ().getValidatedLedgerAge () >= 1min)
1995  }
1996 
1999 
2000  if (mMode == om)
2001  return;
2002 
2003  mMode = om;
2004 
2005  accounting_.mode (om);
2006 
2007  JLOG(m_journal.info()) << "STATE->" << strOperatingMode ();
2008  pubServer ();
2009 }
2010 
2011 
2014  std::string selection, AccountID const& account,
2015  std::int32_t minLedger, std::int32_t maxLedger, bool descending,
2016  std::uint32_t offset, int limit,
2017  bool binary, bool count, bool bUnlimited)
2018 {
2019  std::uint32_t NONBINARY_PAGE_LENGTH = 200;
2020  std::uint32_t BINARY_PAGE_LENGTH = 500;
2021 
2022  std::uint32_t numberOfResults;
2023 
2024  if (count)
2025  {
2026  numberOfResults = 1000000000;
2027  }
2028  else if (limit < 0)
2029  {
2030  numberOfResults = binary ? BINARY_PAGE_LENGTH : NONBINARY_PAGE_LENGTH;
2031  }
2032  else if (!bUnlimited)
2033  {
2034  numberOfResults = std::min (
2035  binary ? BINARY_PAGE_LENGTH : NONBINARY_PAGE_LENGTH,
2036  static_cast<std::uint32_t> (limit));
2037  }
2038  else
2039  {
2040  numberOfResults = limit;
2041  }
2042 
2043  std::string maxClause = "";
2044  std::string minClause = "";
2045 
2046  if (maxLedger != -1)
2047  {
2048  maxClause = boost::str (boost::format (
2049  "AND AccountTransactions.LedgerSeq <= '%u'") % maxLedger);
2050  }
2051 
2052  if (minLedger != -1)
2053  {
2054  minClause = boost::str (boost::format (
2055  "AND AccountTransactions.LedgerSeq >= '%u'") % minLedger);
2056  }
2057 
2058  std::string sql;
2059 
2060  if (count)
2061  sql =
2062  boost::str (boost::format (
2063  "SELECT %s FROM AccountTransactions "
2064  "WHERE Account = '%s' %s %s LIMIT %u, %u;")
2065  % selection
2066  % app_.accountIDCache().toBase58(account)
2067  % maxClause
2068  % minClause
2069  % beast::lexicalCastThrow <std::string> (offset)
2070  % beast::lexicalCastThrow <std::string> (numberOfResults)
2071  );
2072  else
2073  sql =
2074  boost::str (boost::format (
2075  "SELECT %s FROM "
2076  "AccountTransactions INNER JOIN Transactions "
2077  "ON Transactions.TransID = AccountTransactions.TransID "
2078  "WHERE Account = '%s' %s %s "
2079  "ORDER BY AccountTransactions.LedgerSeq %s, "
2080  "AccountTransactions.TxnSeq %s, AccountTransactions.TransID %s "
2081  "LIMIT %u, %u;")
2082  % selection
2083  % app_.accountIDCache().toBase58(account)
2084  % maxClause
2085  % minClause
2086  % (descending ? "DESC" : "ASC")
2087  % (descending ? "DESC" : "ASC")
2088  % (descending ? "DESC" : "ASC")
2089  % beast::lexicalCastThrow <std::string> (offset)
2090  % beast::lexicalCastThrow <std::string> (numberOfResults)
2091  );
2092  JLOG(m_journal.trace()) << "txSQL query: " << sql;
2093  return sql;
2094 }
2095 
2097  AccountID const& account,
2098  std::int32_t minLedger, std::int32_t maxLedger, bool descending,
2099  std::uint32_t offset, int limit, bool bUnlimited)
2100 {
2101  // can be called with no locks
2102  AccountTxs ret;
2103 
2105  "AccountTransactions.LedgerSeq,Status,RawTxn,TxnMeta", account,
2106  minLedger, maxLedger, descending, offset, limit, false, false,
2107  bUnlimited);
2108 
2109  {
2110  auto db = app_.getTxnDB ().checkoutDb ();
2111 
2112  boost::optional<std::uint64_t> ledgerSeq;
2113  boost::optional<std::string> status;
2114  soci::blob sociTxnBlob (*db), sociTxnMetaBlob (*db);
2115  soci::indicator rti, tmi;
2116  Blob rawTxn, txnMeta;
2117 
2118  soci::statement st =
2119  (db->prepare << sql,
2120  soci::into(ledgerSeq),
2121  soci::into(status),
2122  soci::into(sociTxnBlob, rti),
2123  soci::into(sociTxnMetaBlob, tmi));
2124 
2125  st.execute ();
2126  while (st.fetch ())
2127  {
2128  if (soci::i_ok == rti)
2129  convert(sociTxnBlob, rawTxn);
2130  else
2131  rawTxn.clear ();
2132 
2133  if (soci::i_ok == tmi)
2134  convert (sociTxnMetaBlob, txnMeta);
2135  else
2136  txnMeta.clear ();
2137 
2138  auto txn = Transaction::transactionFromSQL (
2139  ledgerSeq, status, rawTxn, app_);
2140 
2141  if (txnMeta.empty ())
2142  { // Work around a bug that could leave the metadata missing
2143  auto const seq = rangeCheckedCast<std::uint32_t>(
2144  ledgerSeq.value_or (0));
2145 
2146  JLOG(m_journal.warn()) <<
2147  "Recovering ledger " << seq <<
2148  ", txn " << txn->getID();
2149 
2150  if (auto l = m_ledgerMaster.getLedgerBySeq(seq))
2151  pendSaveValidated(app_, l, false, false);
2152  }
2153 
2154  if (txn)
2155  ret.emplace_back(
2156  txn,
2157  std::make_shared<TxMeta>(
2158  txn->getID(), txn->getLedger(), txnMeta));
2159  }
2160  }
2161 
2162  return ret;
2163 }
2164 
2166  AccountID const& account,
2167  std::int32_t minLedger, std::int32_t maxLedger, bool descending,
2168  std::uint32_t offset, int limit, bool bUnlimited)
2169 {
2170  // can be called with no locks
2172 
2174  "AccountTransactions.LedgerSeq,Status,RawTxn,TxnMeta", account,
2175  minLedger, maxLedger, descending, offset, limit, true/*binary*/, false,
2176  bUnlimited);
2177 
2178  {
2179  auto db = app_.getTxnDB ().checkoutDb ();
2180 
2181  boost::optional<std::uint64_t> ledgerSeq;
2182  boost::optional<std::string> status;
2183  soci::blob sociTxnBlob (*db), sociTxnMetaBlob (*db);
2184  soci::indicator rti, tmi;
2185 
2186  soci::statement st =
2187  (db->prepare << sql,
2188  soci::into(ledgerSeq),
2189  soci::into(status),
2190  soci::into(sociTxnBlob, rti),
2191  soci::into(sociTxnMetaBlob, tmi));
2192 
2193  st.execute ();
2194  while (st.fetch ())
2195  {
2196  Blob rawTxn;
2197  if (soci::i_ok == rti)
2198  convert (sociTxnBlob, rawTxn);
2199  Blob txnMeta;
2200  if (soci::i_ok == tmi)
2201  convert (sociTxnMetaBlob, txnMeta);
2202 
2203  auto const seq =
2204  rangeCheckedCast<std::uint32_t>(ledgerSeq.value_or (0));
2205 
2206  ret.emplace_back (
2207  std::move(rawTxn), std::move(txnMeta), seq);
2208  }
2209  }
2210 
2211  return ret;
2212 }
2213 
2216  AccountID const& account,
2217  std::int32_t minLedger,
2218  std::int32_t maxLedger,
2219  bool forward,
2221  int limit,
2222  bool bUnlimited)
2223 {
2224  static std::uint32_t const page_length(200);
2225 
2226  Application& app = app_;
2228 
2229  auto bound = [&ret, &app](
2230  std::uint32_t ledger_index,
2231  std::string const& status,
2232  Blob const& rawTxn,
2233  Blob const& rawMeta) {
2234  convertBlobsToTxResult(ret, ledger_index, status, rawTxn, rawMeta, app);
2235  };
2236 
2237  accountTxPage(
2238  app_.getTxnDB(),
2239  app_.accountIDCache(),
2240  std::bind(saveLedgerAsync, std::ref(app_), std::placeholders::_1),
2241  bound,
2242  account,
2243  minLedger,
2244  maxLedger,
2245  forward,
2246  marker,
2247  limit,
2248  bUnlimited,
2249  page_length);
2250 
2251  return ret;
2252 }
2253 
2256  AccountID const& account,
2257  std::int32_t minLedger,
2258  std::int32_t maxLedger,
2259  bool forward,
2261  int limit,
2262  bool bUnlimited)
2263 {
2264  static const std::uint32_t page_length(500);
2265 
2266  MetaTxsList ret;
2267 
2268  auto bound = [&ret](
2269  std::uint32_t ledgerIndex,
2270  std::string const& status,
2271  Blob const& rawTxn,
2272  Blob const& rawMeta) {
2273  ret.emplace_back(std::move(rawTxn), std::move(rawMeta), ledgerIndex);
2274  };
2275 
2276  accountTxPage(
2277  app_.getTxnDB(),
2278  app_.accountIDCache(),
2279  std::bind(saveLedgerAsync, std::ref(app_), std::placeholders::_1),
2280  bound,
2281  account,
2282  minLedger,
2283  maxLedger,
2284  forward,
2285  marker,
2286  limit,
2287  bUnlimited,
2288  page_length);
2289  return ret;
2290 }
2291 
2293  STValidation::ref val, std::string const& source)
2294 {
2295  JLOG(m_journal.debug()) << "recvValidation " << val->getLedgerHash ()
2296  << " from " << source;
2297  pubValidation (val);
2298  return handleNewValidation(app_, val, source);
2299 }
2300 
2302 {
2303  return mConsensus.getJson (true);
2304 }
2305 
2306 Json::Value NetworkOPsImp::getServerInfo (bool human, bool admin, bool counters)
2307 {
2309 
2310  // System-level warnings
2311  {
2312  Json::Value warnings{Json::arrayValue};
2313  if (isAmendmentBlocked())
2314  {
2315  Json::Value& w = warnings.append(Json::objectValue);
2316  w[jss::id] = warnRPC_AMENDMENT_BLOCKED;
2317  w[jss::message] =
2318  "This server is amendment blocked, and must be updated to be "
2319  "able to stay in sync with the network.";
2320  }
2321  if (admin && isAmendmentWarned())
2322  {
2323  Json::Value& w = warnings.append(Json::objectValue);
2324  w[jss::id] = warnRPC_UNSUPPORTED_MAJORITY;
2325  w[jss::message] =
2326  "One or more unsupported amendments have reached majority. "
2327  "Upgrade to the latest version before they are activated "
2328  "to avoid being amendment blocked.";
2329  if (auto const expected =
2331  {
2332  auto& d = w[jss::details] = Json::objectValue;
2333  d[jss::expected_date] = expected->time_since_epoch().count();
2334  d[jss::expected_date_UTC] = to_string(*expected);
2335  }
2336  }
2337 
2338  if (warnings.size())
2339  info[jss::warnings] = std::move(warnings);
2340  }
2341 
2342  // hostid: unique string describing the machine
2343  if (human)
2344  info [jss::hostid] = getHostId (admin);
2345 
2346  if (auto const netid = app_.overlay().networkID())
2347  info [jss::network_id] = static_cast<Json::UInt>(*netid);
2348 
2349  info [jss::build_version] = BuildInfo::getVersionString ();
2350 
2351  info [jss::server_state] = strOperatingMode (admin);
2352 
2353  info [jss::time] = to_string(date::floor<std::chrono::microseconds>(
2355 
2356  if (needNetworkLedger_)
2357  info[jss::network_ledger] = "waiting";
2358 
2359  info[jss::validation_quorum] = static_cast<Json::UInt>(
2360  app_.validators ().quorum ());
2361 
2362  if (admin)
2363  {
2364  auto when = app_.validators().expires();
2365 
2366  if (!human)
2367  {
2368  if (when)
2369  info[jss::validator_list_expires] =
2370  safe_cast<Json::UInt>(when->time_since_epoch().count());
2371  else
2372  info[jss::validator_list_expires] = 0;
2373  }
2374  else
2375  {
2376  auto& x = (info[jss::validator_list] = Json::objectValue);
2377 
2378  x[jss::count] = static_cast<Json::UInt>(app_.validators().count());
2379 
2380  if (when)
2381  {
2382  if (*when == TimeKeeper::time_point::max())
2383  {
2384  x[jss::expiration] = "never";
2385  x[jss::status] = "active";
2386  }
2387  else
2388  {
2389  x[jss::expiration] = to_string(*when);
2390 
2391  if (*when > app_.timeKeeper().now())
2392  x[jss::status] = "active";
2393  else
2394  x[jss::status] = "expired";
2395  }
2396  }
2397  else
2398  {
2399  x[jss::status] = "unknown";
2400  x[jss::expiration] = "unknown";
2401  }
2402  }
2403  }
2404  info[jss::io_latency_ms] = static_cast<Json::UInt> (
2405  app_.getIOLatency().count());
2406 
2407  if (admin)
2408  {
2410  {
2411  info[jss::pubkey_validator] = toBase58 (
2414  }
2415  else
2416  {
2417  info[jss::pubkey_validator] = "none";
2418  }
2419  }
2420 
2421  if (counters)
2422  {
2423  info[jss::counters] = app_.getPerfLog().countersJson();
2424  info[jss::current_activities] = app_.getPerfLog().currentJson();
2425  }
2426 
2427  info[jss::pubkey_node] = toBase58 (
2429  app_.nodeIdentity().first);
2430 
2431  info[jss::complete_ledgers] =
2433 
2434  if (amendmentBlocked_)
2435  info[jss::amendment_blocked] = true;
2436 
2437  auto const fp = m_ledgerMaster.getFetchPackCacheSize ();
2438 
2439  if (fp != 0)
2440  info[jss::fetch_pack] = Json::UInt (fp);
2441 
2442  info[jss::peers] = Json::UInt (app_.overlay ().size ());
2443 
2444  Json::Value lastClose = Json::objectValue;
2445  lastClose[jss::proposers] = Json::UInt(mConsensus.prevProposers());
2446 
2447  if (human)
2448  {
2449  lastClose[jss::converge_time_s] =
2452  }
2453  else
2454  {
2455  lastClose[jss::converge_time] =
2457  }
2458 
2459  info[jss::last_close] = lastClose;
2460 
2461  // info[jss::consensus] = mConsensus.getJson();
2462 
2463  if (admin)
2464  info[jss::load] = m_job_queue.getJson ();
2465 
2466  auto const escalationMetrics = app_.getTxQ().getMetrics(
2467  *app_.openLedger().current());
2468 
2469  auto const loadFactorServer = app_.getFeeTrack().getLoadFactor();
2470  auto const loadBaseServer = app_.getFeeTrack().getLoadBase();
2471  /* Scale the escalated fee level to unitless "load factor".
2472  In practice, this just strips the units, but it will continue
2473  to work correctly if either base value ever changes. */
2474  auto const loadFactorFeeEscalation = mulDiv(
2475  escalationMetrics.openLedgerFeeLevel, loadBaseServer,
2476  escalationMetrics.referenceFeeLevel).second;
2477 
2478  auto const loadFactor = std::max(safe_cast<std::uint64_t>(loadFactorServer),
2479  loadFactorFeeEscalation);
2480 
2481  if (!human)
2482  {
2483  info[jss::load_base] = loadBaseServer;
2484  info[jss::load_factor] = trunc32(loadFactor);
2485  info[jss::load_factor_server] = loadFactorServer;
2486 
2487  /* Json::Value doesn't support uint64, so clamp to max
2488  uint32 value. This is mostly theoretical, since there
2489  probably isn't enough extant XRP to drive the factor
2490  that high.
2491  */
2492  info[jss::load_factor_fee_escalation] =
2493  escalationMetrics.openLedgerFeeLevel.jsonClipped();
2494  info[jss::load_factor_fee_queue] =
2495  escalationMetrics.minProcessingFeeLevel.jsonClipped();
2496  info[jss::load_factor_fee_reference] =
2497  escalationMetrics.referenceFeeLevel.jsonClipped();
2498  }
2499  else
2500  {
2501  info[jss::load_factor] = static_cast<double> (loadFactor) / loadBaseServer;
2502 
2503  if (loadFactorServer != loadFactor)
2504  info[jss::load_factor_server] =
2505  static_cast<double> (loadFactorServer) / loadBaseServer;
2506 
2507  if (admin)
2508  {
2510  if (fee != loadBaseServer)
2511  info[jss::load_factor_local] =
2512  static_cast<double> (fee) / loadBaseServer;
2513  fee = app_.getFeeTrack ().getRemoteFee();
2514  if (fee != loadBaseServer)
2515  info[jss::load_factor_net] =
2516  static_cast<double> (fee) / loadBaseServer;
2517  fee = app_.getFeeTrack().getClusterFee();
2518  if (fee != loadBaseServer)
2519  info[jss::load_factor_cluster] =
2520  static_cast<double> (fee) / loadBaseServer;
2521  }
2522  if (escalationMetrics.openLedgerFeeLevel !=
2523  escalationMetrics.referenceFeeLevel &&
2524  (admin ||
2525  loadFactorFeeEscalation != loadFactor))
2526  info[jss::load_factor_fee_escalation] =
2527  escalationMetrics.openLedgerFeeLevel.decimalFromReference(
2528  escalationMetrics.referenceFeeLevel);
2529  if (escalationMetrics.minProcessingFeeLevel !=
2530  escalationMetrics.referenceFeeLevel)
2531  info[jss::load_factor_fee_queue] =
2532  escalationMetrics.minProcessingFeeLevel.decimalFromReference(
2533  escalationMetrics.referenceFeeLevel);
2534  }
2535 
2536  bool valid = false;
2537  auto lpClosed = m_ledgerMaster.getValidatedLedger ();
2538 
2539  if (lpClosed)
2540  valid = true;
2541  else
2542  lpClosed = m_ledgerMaster.getClosedLedger ();
2543 
2544  if (lpClosed)
2545  {
2546  XRPAmount const baseFee = lpClosed->fees().base;
2548  l[jss::seq] = Json::UInt (lpClosed->info().seq);
2549  l[jss::hash] = to_string (lpClosed->info().hash);
2550 
2551  if (!human)
2552  {
2553  l[jss::base_fee] = baseFee.jsonClipped();
2554  l[jss::reserve_base] = lpClosed->fees().accountReserve(0).jsonClipped();
2555  l[jss::reserve_inc] =
2556  lpClosed->fees().increment.jsonClipped();
2557  l[jss::close_time] = Json::Value::UInt (
2558  lpClosed->info().closeTime.time_since_epoch().count());
2559  }
2560  else
2561  {
2562  l[jss::base_fee_xrp] =
2563  baseFee.decimalXRP();
2564  l[jss::reserve_base_xrp] =
2565  lpClosed->fees().accountReserve(0).decimalXRP();
2566  l[jss::reserve_inc_xrp] =
2567  lpClosed->fees().increment.decimalXRP();
2568 
2569  auto const nowOffset = app_.timeKeeper().nowOffset();
2570  if (std::abs (nowOffset.count()) >= 60)
2571  l[jss::system_time_offset] = nowOffset.count();
2572 
2573  auto const closeOffset = app_.timeKeeper().closeOffset();
2574  if (std::abs (closeOffset.count()) >= 60)
2575  l[jss::close_time_offset] = closeOffset.count();
2576 
2577  auto lCloseTime = lpClosed->info().closeTime;
2578  auto closeTime = app_.timeKeeper().closeTime();
2579  if (lCloseTime <= closeTime)
2580  {
2581  using namespace std::chrono_literals;
2582  auto age = closeTime - lCloseTime;
2583  if (age < 1000000s)
2584  l[jss::age] = Json::UInt (age.count());
2585  else
2586  l[jss::age] = 0;
2587  }
2588  }
2589 
2590  if (valid)
2591  info[jss::validated_ledger] = l;
2592  else
2593  info[jss::closed_ledger] = l;
2594 
2595  auto lpPublished = m_ledgerMaster.getPublishedLedger ();
2596  if (! lpPublished)
2597  info[jss::published_ledger] = "none";
2598  else if (lpPublished->info().seq != lpClosed->info().seq)
2599  info[jss::published_ledger] = lpPublished->info().seq;
2600  }
2601 
2602  std::tie(info[jss::state_accounting],
2603  info[jss::server_state_duration_us]) = accounting_.json();
2604  info[jss::uptime] = UptimeClock::now().time_since_epoch().count();
2605  info[jss::jq_trans_overflow] = std::to_string(
2607  info[jss::peer_disconnects] = std::to_string(
2609  info[jss::peer_disconnects_resources] = std::to_string(
2611 
2612  return info;
2613 }
2614 
2616 {
2618 }
2619 
2621 {
2622  return app_.getInboundLedgers().getInfo();
2623 }
2624 
2626  std::shared_ptr<ReadView const> const& lpCurrent,
2627  std::shared_ptr<STTx const> const& stTxn, TER terResult)
2628 {
2629  Json::Value jvObj = transJson (*stTxn, terResult, false, lpCurrent);
2630 
2631  {
2633 
2634  auto it = mStreamMaps[sRTTransactions].begin ();
2635  while (it != mStreamMaps[sRTTransactions].end ())
2636  {
2637  InfoSub::pointer p = it->second.lock ();
2638 
2639  if (p)
2640  {
2641  p->send (jvObj, true);
2642  ++it;
2643  }
2644  else
2645  {
2646  it = mStreamMaps[sRTTransactions].erase (it);
2647  }
2648  }
2649  }
2650  AcceptedLedgerTx alt (lpCurrent, stTxn, terResult,
2651  app_.accountIDCache(), app_.logs());
2652  JLOG(m_journal.trace()) << "pubProposed: " << alt.getJson ();
2653  pubAccountTransaction (lpCurrent, alt, false);
2654 }
2655 
2657  std::shared_ptr<ReadView const> const& lpAccepted)
2658 {
2659  // Ledgers are published only when they acquire sufficient validations
2660  // Holes are filled across connection loss or other catastrophe
2661 
2662  std::shared_ptr<AcceptedLedger> alpAccepted =
2663  app_.getAcceptedLedgerCache().fetch (lpAccepted->info().hash);
2664  if (! alpAccepted)
2665  {
2666  alpAccepted = std::make_shared<AcceptedLedger> (
2667  lpAccepted, app_.accountIDCache(), app_.logs());
2668  app_.getAcceptedLedgerCache().canonicalize_replace_client(
2669  lpAccepted->info().hash, alpAccepted);
2670  }
2671 
2672  {
2674 
2675  if (!mStreamMaps[sLedger].empty ())
2676  {
2678 
2679  jvObj[jss::type] = "ledgerClosed";
2680  jvObj[jss::ledger_index] = lpAccepted->info().seq;
2681  jvObj[jss::ledger_hash] = to_string (lpAccepted->info().hash);
2682  jvObj[jss::ledger_time]
2683  = Json::Value::UInt (lpAccepted->info().closeTime.time_since_epoch().count());
2684 
2685  jvObj[jss::fee_ref] = lpAccepted->fees().units.jsonClipped();
2686  jvObj[jss::fee_base] = lpAccepted->fees().base.jsonClipped();
2687  jvObj[jss::reserve_base] =
2688  lpAccepted->fees().accountReserve(0).jsonClipped();
2689  jvObj[jss::reserve_inc] = lpAccepted->fees().increment.jsonClipped();
2690 
2691  jvObj[jss::txn_count] = Json::UInt (alpAccepted->getTxnCount ());
2692 
2694  {
2695  jvObj[jss::validated_ledgers]
2697  }
2698 
2699  auto it = mStreamMaps[sLedger].begin ();
2700  while (it != mStreamMaps[sLedger].end ())
2701  {
2702  InfoSub::pointer p = it->second.lock ();
2703  if (p)
2704  {
2705  p->send (jvObj, true);
2706  ++it;
2707  }
2708  else
2709  it = mStreamMaps[sLedger].erase (it);
2710  }
2711  }
2712  }
2713 
2714  // Don't lock since pubAcceptedTransaction is locking.
2715  for (auto const& [_, accTx] : alpAccepted->getMap ())
2716  {
2717  (void)_;
2718  JLOG(m_journal.trace()) << "pubAccepted: " << accTx->getJson ();
2719  pubValidatedTransaction (lpAccepted, *accTx);
2720  }
2721 }
2722 
2724 {
2725  ServerFeeSummary f{app_.openLedger().current()->fees().base,
2727  app_.getFeeTrack()};
2728 
2729  // only schedule the job if something has changed
2730  if (f != mLastFeeSummary)
2731  {
2733  jtCLIENT, "reportFeeChange->pubServer",
2734  [this] (Job&) { pubServer(); });
2735  }
2736 }
2737 
2739 {
2741  jtCLIENT, "reportConsensusStateChange->pubConsensus",
2742  [this, phase] (Job&) { pubConsensus(phase); });
2743 }
2744 
2745 // This routine should only be used to publish accepted or validated
2746 // transactions.
2748  const STTx& stTxn, TER terResult, bool bValidated,
2749  std::shared_ptr<ReadView const> const& lpCurrent)
2750 {
2752  std::string sToken;
2753  std::string sHuman;
2754 
2755  transResultInfo (terResult, sToken, sHuman);
2756 
2757  jvObj[jss::type] = "transaction";
2758  jvObj[jss::transaction] = stTxn.getJson (JsonOptions::none);
2759 
2760  if (bValidated)
2761  {
2762  jvObj[jss::ledger_index] = lpCurrent->info().seq;
2763  jvObj[jss::ledger_hash] = to_string (lpCurrent->info().hash);
2764  jvObj[jss::transaction][jss::date] =
2765  lpCurrent->info().closeTime.time_since_epoch().count();
2766  jvObj[jss::validated] = true;
2767 
2768  // WRITEME: Put the account next seq here
2769 
2770  }
2771  else
2772  {
2773  jvObj[jss::validated] = false;
2774  jvObj[jss::ledger_current_index] = lpCurrent->info().seq;
2775  }
2776 
2777  jvObj[jss::status] = bValidated ? "closed" : "proposed";
2778  jvObj[jss::engine_result] = sToken;
2779  jvObj[jss::engine_result_code] = terResult;
2780  jvObj[jss::engine_result_message] = sHuman;
2781 
2782  if (stTxn.getTxnType() == ttOFFER_CREATE)
2783  {
2784  auto const account = stTxn.getAccountID(sfAccount);
2785  auto const amount = stTxn.getFieldAmount (sfTakerGets);
2786 
2787  // If the offer create is not self funded then add the owner balance
2788  if (account != amount.issue ().account)
2789  {
2790  auto const ownerFunds = accountFunds(*lpCurrent,
2791  account, amount, fhIGNORE_FREEZE, app_.journal ("View"));
2792  jvObj[jss::transaction][jss::owner_funds] = ownerFunds.getText ();
2793  }
2794  }
2795 
2796  return jvObj;
2797 }
2798 
2800  std::shared_ptr<ReadView const> const& alAccepted,
2801  const AcceptedLedgerTx& alTx)
2802 {
2803  std::shared_ptr<STTx const> stTxn = alTx.getTxn();
2804  Json::Value jvObj = transJson (
2805  *stTxn, alTx.getResult (), true, alAccepted);
2806 
2807  if (auto const txMeta = alTx.getMeta())
2808  {
2809  jvObj[jss::meta] = txMeta->getJson(JsonOptions::none);
2811  jvObj[jss::meta], *alAccepted, stTxn, *txMeta);
2812  }
2813 
2814  {
2816 
2817  auto it = mStreamMaps[sTransactions].begin ();
2818  while (it != mStreamMaps[sTransactions].end ())
2819  {
2820  InfoSub::pointer p = it->second.lock ();
2821 
2822  if (p)
2823  {
2824  p->send (jvObj, true);
2825  ++it;
2826  }
2827  else
2828  it = mStreamMaps[sTransactions].erase (it);
2829  }
2830 
2831  it = mStreamMaps[sRTTransactions].begin ();
2832 
2833  while (it != mStreamMaps[sRTTransactions].end ())
2834  {
2835  InfoSub::pointer p = it->second.lock ();
2836 
2837  if (p)
2838  {
2839  p->send (jvObj, true);
2840  ++it;
2841  }
2842  else
2843  it = mStreamMaps[sRTTransactions].erase (it);
2844  }
2845  }
2846  app_.getOrderBookDB ().processTxn (alAccepted, alTx, jvObj);
2847  pubAccountTransaction (alAccepted, alTx, true);
2848 }
2849 
2851  std::shared_ptr<ReadView const> const& lpCurrent,
2852  const AcceptedLedgerTx& alTx,
2853  bool bAccepted)
2854 {
2856  int iProposed = 0;
2857  int iAccepted = 0;
2858 
2859  {
2861 
2862  if (!bAccepted && mSubRTAccount.empty ()) return;
2863 
2864  if (!mSubAccount.empty () || (!mSubRTAccount.empty ()) )
2865  {
2866  for (auto const& affectedAccount: alTx.getAffected ())
2867  {
2868  auto simiIt
2869  = mSubRTAccount.find (affectedAccount);
2870  if (simiIt != mSubRTAccount.end ())
2871  {
2872  auto it = simiIt->second.begin ();
2873 
2874  while (it != simiIt->second.end ())
2875  {
2876  InfoSub::pointer p = it->second.lock ();
2877 
2878  if (p)
2879  {
2880  notify.insert (p);
2881  ++it;
2882  ++iProposed;
2883  }
2884  else
2885  it = simiIt->second.erase (it);
2886  }
2887  }
2888 
2889  if (bAccepted)
2890  {
2891  simiIt = mSubAccount.find (affectedAccount);
2892 
2893  if (simiIt != mSubAccount.end ())
2894  {
2895  auto it = simiIt->second.begin ();
2896  while (it != simiIt->second.end ())
2897  {
2898  InfoSub::pointer p = it->second.lock ();
2899 
2900  if (p)
2901  {
2902  notify.insert (p);
2903  ++it;
2904  ++iAccepted;
2905  }
2906  else
2907  it = simiIt->second.erase (it);
2908  }
2909  }
2910  }
2911  }
2912  }
2913  }
2914  JLOG(m_journal.trace()) << "pubAccountTransaction:" <<
2915  " iProposed=" << iProposed <<
2916  " iAccepted=" << iAccepted;
2917 
2918  if (!notify.empty ())
2919  {
2920  std::shared_ptr<STTx const> stTxn = alTx.getTxn();
2921  Json::Value jvObj = transJson (
2922  *stTxn, alTx.getResult (), bAccepted, lpCurrent);
2923 
2924  if (alTx.isApplied ())
2925  {
2926  if (auto const txMeta = alTx.getMeta())
2927  {
2928  jvObj[jss::meta] = txMeta->getJson(JsonOptions::none);
2930  jvObj[jss::meta], *lpCurrent, stTxn, *txMeta);
2931  }
2932  }
2933 
2934  for (InfoSub::ref isrListener : notify)
2935  isrListener->send (jvObj, true);
2936  }
2937 }
2938 
2939 //
2940 // Monitoring
2941 //
2942 
2944  InfoSub::ref isrListener,
2945  hash_set<AccountID> const& vnaAccountIDs, bool rt)
2946 {
2947  SubInfoMapType& subMap = rt ? mSubRTAccount : mSubAccount;
2948 
2949  for (auto const& naAccountID : vnaAccountIDs)
2950  {
2951  JLOG(m_journal.trace()) <<
2952  "subAccount: account: " << toBase58(naAccountID);
2953 
2954  isrListener->insertSubAccountInfo (naAccountID, rt);
2955  }
2956 
2958 
2959  for (auto const& naAccountID : vnaAccountIDs)
2960  {
2961  auto simIterator = subMap.find (naAccountID);
2962  if (simIterator == subMap.end ())
2963  {
2964  // Not found, note that account has a new single listner.
2965  SubMapType usisElement;
2966  usisElement[isrListener->getSeq ()] = isrListener;
2967  // VFALCO NOTE This is making a needless copy of naAccountID
2968  subMap.insert (simIterator,
2969  make_pair(naAccountID, usisElement));
2970  }
2971  else
2972  {
2973  // Found, note that the account has another listener.
2974  simIterator->second[isrListener->getSeq ()] = isrListener;
2975  }
2976  }
2977 }
2978 
2980  InfoSub::ref isrListener,
2981  hash_set<AccountID> const& vnaAccountIDs,
2982  bool rt)
2983 {
2984  for (auto const& naAccountID : vnaAccountIDs)
2985  {
2986  // Remove from the InfoSub
2987  isrListener->deleteSubAccountInfo(naAccountID, rt);
2988  }
2989 
2990  // Remove from the server
2991  unsubAccountInternal (isrListener->getSeq(), vnaAccountIDs, rt);
2992 }
2993 
2995  std::uint64_t uSeq,
2996  hash_set<AccountID> const& vnaAccountIDs,
2997  bool rt)
2998 {
3000 
3001  SubInfoMapType& subMap = rt ? mSubRTAccount : mSubAccount;
3002 
3003  for (auto const& naAccountID : vnaAccountIDs)
3004  {
3005  auto simIterator = subMap.find (naAccountID);
3006 
3007  if (simIterator != subMap.end ())
3008  {
3009  // Found
3010  simIterator->second.erase (uSeq);
3011 
3012  if (simIterator->second.empty ())
3013  {
3014  // Don't need hash entry.
3015  subMap.erase (simIterator);
3016  }
3017  }
3018  }
3019 }
3020 
3021 bool NetworkOPsImp::subBook (InfoSub::ref isrListener, Book const& book)
3022 {
3023  if (auto listeners = app_.getOrderBookDB ().makeBookListeners (book))
3024  listeners->addSubscriber (isrListener);
3025  else
3026  assert (false);
3027  return true;
3028 }
3029 
3031 {
3032  if (auto listeners = app_.getOrderBookDB ().getBookListeners (book))
3033  listeners->removeSubscriber (uSeq);
3034 
3035  return true;
3036 }
3037 
3039  boost::optional<std::chrono::milliseconds> consensusDelay)
3040 {
3041  // This code-path is exclusively used when the server is in standalone
3042  // mode via `ledger_accept`
3043  assert (m_standalone);
3044 
3045  if (!m_standalone)
3046  Throw<std::runtime_error> ("Operation only possible in STANDALONE mode.");
3047 
3048  // FIXME Could we improve on this and remove the need for a specialized
3049  // API in Consensus?
3051  mConsensus.simulate (app_.timeKeeper().closeTime(), consensusDelay);
3052  return m_ledgerMaster.getCurrentLedger ()->info().seq;
3053 }
3054 
3055 // <-- bool: true=added, false=already there
3057 {
3058  if (auto lpClosed = m_ledgerMaster.getValidatedLedger ())
3059  {
3060  jvResult[jss::ledger_index] = lpClosed->info().seq;
3061  jvResult[jss::ledger_hash] = to_string (lpClosed->info().hash);
3062  jvResult[jss::ledger_time] = Json::Value::UInt(
3063  lpClosed->info().closeTime.time_since_epoch().count());
3064  jvResult[jss::fee_ref] = lpClosed->fees().units.jsonClipped();
3065  jvResult[jss::fee_base] = lpClosed->fees().base.jsonClipped();
3066  jvResult[jss::reserve_base] =
3067  lpClosed->fees().accountReserve(0).jsonClipped();
3068  jvResult[jss::reserve_inc] = lpClosed->fees().increment.jsonClipped();
3069  }
3070 
3072  {
3073  jvResult[jss::validated_ledgers]
3075  }
3076 
3078  return mStreamMaps[sLedger].emplace (
3079  isrListener->getSeq (), isrListener).second;
3080 }
3081 
3082 // <-- bool: true=erased, false=was not there
3084 {
3086  return mStreamMaps[sLedger].erase (uSeq);
3087 }
3088 
3089 // <-- bool: true=added, false=already there
3091 {
3093  return mStreamMaps[sManifests].emplace (
3094  isrListener->getSeq (), isrListener).second;
3095 }
3096 
3097 // <-- bool: true=erased, false=was not there
3099 {
3101  return mStreamMaps[sManifests].erase (uSeq);
3102 }
3103 
3104 // <-- bool: true=added, false=already there
3106  bool admin)
3107 {
3108  uint256 uRandom;
3109 
3110  if (m_standalone)
3111  jvResult[jss::stand_alone] = m_standalone;
3112 
3113  // CHECKME: is it necessary to provide a random number here?
3114  beast::rngfill (
3115  uRandom.begin(),
3116  uRandom.size(),
3117  crypto_prng());
3118 
3119  auto const& feeTrack = app_.getFeeTrack();
3120  jvResult[jss::random] = to_string (uRandom);
3121  jvResult[jss::server_status] = strOperatingMode (admin);
3122  jvResult[jss::load_base] = feeTrack.getLoadBase ();
3123  jvResult[jss::load_factor] = feeTrack.getLoadFactor ();
3124  jvResult [jss::hostid] = getHostId (admin);
3125  jvResult[jss::pubkey_node] = toBase58 (
3127  app_.nodeIdentity().first);
3128 
3130  return mStreamMaps[sServer].emplace (
3131  isrListener->getSeq (), isrListener).second;
3132 }
3133 
3134 // <-- bool: true=erased, false=was not there
3136 {
3138  return mStreamMaps[sServer].erase (uSeq);
3139 }
3140 
3141 // <-- bool: true=added, false=already there
3143 {
3145  return mStreamMaps[sTransactions].emplace (
3146  isrListener->getSeq (), isrListener).second;
3147 }
3148 
3149 // <-- bool: true=erased, false=was not there
3151 {
3153  return mStreamMaps[sTransactions].erase (uSeq);
3154 }
3155 
3156 // <-- bool: true=added, false=already there
3158 {
3160  return mStreamMaps[sRTTransactions].emplace (
3161  isrListener->getSeq (), isrListener).second;
3162 }
3163 
3164 // <-- bool: true=erased, false=was not there
3166 {
3168  return mStreamMaps[sRTTransactions].erase (uSeq);
3169 }
3170 
3171 // <-- bool: true=added, false=already there
3173 {
3175  return mStreamMaps[sValidations].emplace (
3176  isrListener->getSeq (), isrListener).second;
3177 }
3178 
3179 // <-- bool: true=erased, false=was not there
3181 {
3183  return mStreamMaps[sValidations].erase (uSeq);
3184 }
3185 
3186 // <-- bool: true=added, false=already there
3188 {
3190  return mStreamMaps[sPeerStatus].emplace (
3191  isrListener->getSeq (), isrListener).second;
3192 }
3193 
3194 // <-- bool: true=erased, false=was not there
3196 {
3198  return mStreamMaps[sPeerStatus].erase (uSeq);
3199 }
3200 
3201 // <-- bool: true=added, false=already there
3203 {
3205  return mStreamMaps[sConsensusPhase].emplace (
3206  isrListener->getSeq (), isrListener).second;
3207 }
3208 
3209 // <-- bool: true=erased, false=was not there
3211 {
3213  return mStreamMaps[sConsensusPhase].erase (uSeq);
3214 }
3215 
3217 {
3219 
3220  subRpcMapType::iterator it = mRpcSubMap.find (strUrl);
3221 
3222  if (it != mRpcSubMap.end ())
3223  return it->second;
3224 
3225  return InfoSub::pointer ();
3226 }
3227 
3229  std::string const& strUrl, InfoSub::ref rspEntry)
3230 {
3232 
3233  mRpcSubMap.emplace (strUrl, rspEntry);
3234 
3235  return rspEntry;
3236 }
3237 
3239 {
3241  auto pInfo = findRpcSub(strUrl);
3242 
3243  if (!pInfo)
3244  return false;
3245 
3246  // check to see if any of the stream maps still hold a weak reference to
3247  // this entry before removing
3248  for (SubMapType const& map : mStreamMaps)
3249  {
3250  if (map.find(pInfo->getSeq()) != map.end())
3251  return false;
3252  }
3253  mRpcSubMap.erase(strUrl);
3254  return true;
3255 }
3256 
3257 #ifndef USE_NEW_BOOK_PAGE
3258 
3259 // NIKB FIXME this should be looked at. There's no reason why this shouldn't
3260 // work, but it demonstrated poor performance.
3261 //
3264  Book const& book,
3265  AccountID const& uTakerID,
3266  bool const bProof,
3267  unsigned int iLimit,
3268  Json::Value const& jvMarker,
3269  Json::Value& jvResult)
3270 { // CAUTION: This is the old get book page logic
3271  Json::Value& jvOffers =
3272  (jvResult[jss::offers] = Json::Value (Json::arrayValue));
3273 
3275  const uint256 uBookBase = getBookBase (book);
3276  const uint256 uBookEnd = getQualityNext (uBookBase);
3277  uint256 uTipIndex = uBookBase;
3278 
3279  if (auto stream = m_journal.trace())
3280  {
3281  stream << "getBookPage:" << book;
3282  stream << "getBookPage: uBookBase=" << uBookBase;
3283  stream << "getBookPage: uBookEnd=" << uBookEnd;
3284  stream << "getBookPage: uTipIndex=" << uTipIndex;
3285  }
3286 
3287  ReadView const& view = *lpLedger;
3288 
3289  bool const bGlobalFreeze =
3290  isGlobalFrozen(view, book.out.account) ||
3291  isGlobalFrozen(view, book.in.account);
3292 
3293  bool bDone = false;
3294  bool bDirectAdvance = true;
3295 
3296  std::shared_ptr<SLE const> sleOfferDir;
3297  uint256 offerIndex;
3298  unsigned int uBookEntry;
3299  STAmount saDirRate;
3300 
3301  auto const rate = transferRate(view, book.out.account);
3302  auto viewJ = app_.journal ("View");
3303 
3304  while (! bDone && iLimit-- > 0)
3305  {
3306  if (bDirectAdvance)
3307  {
3308  bDirectAdvance = false;
3309 
3310  JLOG(m_journal.trace()) << "getBookPage: bDirectAdvance";
3311 
3312  auto const ledgerIndex = view.succ(uTipIndex, uBookEnd);
3313  if (ledgerIndex)
3314  sleOfferDir = view.read(keylet::page(*ledgerIndex));
3315  else
3316  sleOfferDir.reset();
3317 
3318  if (!sleOfferDir)
3319  {
3320  JLOG(m_journal.trace()) << "getBookPage: bDone";
3321  bDone = true;
3322  }
3323  else
3324  {
3325  uTipIndex = sleOfferDir->key();
3326  saDirRate = amountFromQuality (getQuality (uTipIndex));
3327 
3328  cdirFirst (view,
3329  uTipIndex, sleOfferDir, uBookEntry, offerIndex, viewJ);
3330 
3331  JLOG(m_journal.trace())
3332  << "getBookPage: uTipIndex=" << uTipIndex;
3333  JLOG(m_journal.trace())
3334  << "getBookPage: offerIndex=" << offerIndex;
3335  }
3336  }
3337 
3338  if (!bDone)
3339  {
3340  auto sleOffer = view.read(keylet::offer(offerIndex));
3341 
3342  if (sleOffer)
3343  {
3344  auto const uOfferOwnerID =
3345  sleOffer->getAccountID (sfAccount);
3346  auto const& saTakerGets =
3347  sleOffer->getFieldAmount (sfTakerGets);
3348  auto const& saTakerPays =
3349  sleOffer->getFieldAmount (sfTakerPays);
3350  STAmount saOwnerFunds;
3351  bool firstOwnerOffer (true);
3352 
3353  if (book.out.account == uOfferOwnerID)
3354  {
3355  // If an offer is selling issuer's own IOUs, it is fully
3356  // funded.
3357  saOwnerFunds = saTakerGets;
3358  }
3359  else if (bGlobalFreeze)
3360  {
3361  // If either asset is globally frozen, consider all offers
3362  // that aren't ours to be totally unfunded
3363  saOwnerFunds.clear (book.out);
3364  }
3365  else
3366  {
3367  auto umBalanceEntry = umBalance.find (uOfferOwnerID);
3368  if (umBalanceEntry != umBalance.end ())
3369  {
3370  // Found in running balance table.
3371 
3372  saOwnerFunds = umBalanceEntry->second;
3373  firstOwnerOffer = false;
3374  }
3375  else
3376  {
3377  // Did not find balance in table.
3378 
3379  saOwnerFunds = accountHolds (view,
3380  uOfferOwnerID, book.out.currency,
3381  book.out.account, fhZERO_IF_FROZEN, viewJ);
3382 
3383  if (saOwnerFunds < beast::zero)
3384  {
3385  // Treat negative funds as zero.
3386 
3387  saOwnerFunds.clear ();
3388  }
3389  }
3390  }
3391 
3392  Json::Value jvOffer = sleOffer->getJson (JsonOptions::none);
3393 
3394  STAmount saTakerGetsFunded;
3395  STAmount saOwnerFundsLimit = saOwnerFunds;
3396  Rate offerRate = parityRate;
3397 
3398  if (rate != parityRate
3399  // Have a tranfer fee.
3400  && uTakerID != book.out.account
3401  // Not taking offers of own IOUs.
3402  && book.out.account != uOfferOwnerID)
3403  // Offer owner not issuing ownfunds
3404  {
3405  // Need to charge a transfer fee to offer owner.
3406  offerRate = rate;
3407  saOwnerFundsLimit = divide (
3408  saOwnerFunds, offerRate);
3409  }
3410 
3411  if (saOwnerFundsLimit >= saTakerGets)
3412  {
3413  // Sufficient funds no shenanigans.
3414  saTakerGetsFunded = saTakerGets;
3415  }
3416  else
3417  {
3418  // Only provide, if not fully funded.
3419 
3420  saTakerGetsFunded = saOwnerFundsLimit;
3421 
3422  saTakerGetsFunded.setJson (jvOffer[jss::taker_gets_funded]);
3423  std::min (
3424  saTakerPays, multiply (
3425  saTakerGetsFunded, saDirRate, saTakerPays.issue ())).setJson
3426  (jvOffer[jss::taker_pays_funded]);
3427  }
3428 
3429  STAmount saOwnerPays = (parityRate == offerRate)
3430  ? saTakerGetsFunded
3431  : std::min (
3432  saOwnerFunds,
3433  multiply (saTakerGetsFunded, offerRate));
3434 
3435  umBalance[uOfferOwnerID] = saOwnerFunds - saOwnerPays;
3436 
3437  // Include all offers funded and unfunded
3438  Json::Value& jvOf = jvOffers.append (jvOffer);
3439  jvOf[jss::quality] = saDirRate.getText ();
3440 
3441  if (firstOwnerOffer)
3442  jvOf[jss::owner_funds] = saOwnerFunds.getText ();
3443  }
3444  else
3445  {
3446  JLOG(m_journal.warn()) << "Missing offer";
3447  }
3448 
3449  if (! cdirNext(view,
3450  uTipIndex, sleOfferDir, uBookEntry, offerIndex, viewJ))
3451  {
3452  bDirectAdvance = true;
3453  }
3454  else
3455  {
3456  JLOG(m_journal.trace())
3457  << "getBookPage: offerIndex=" << offerIndex;
3458  }
3459  }
3460  }
3461 
3462  // jvResult[jss::marker] = Json::Value(Json::arrayValue);
3463  // jvResult[jss::nodes] = Json::Value(Json::arrayValue);
3464 }
3465 
3466 
3467 #else
3468 
3469 // This is the new code that uses the book iterators
3470 // It has temporarily been disabled
3471 
3474  Book const& book,
3475  AccountID const& uTakerID,
3476  bool const bProof,
3477  unsigned int iLimit,
3478  Json::Value const& jvMarker,
3479  Json::Value& jvResult)
3480 {
3481  auto& jvOffers = (jvResult[jss::offers] = Json::Value (Json::arrayValue));
3482 
3484 
3485  MetaView lesActive (lpLedger, tapNONE, true);
3486  OrderBookIterator obIterator (lesActive, book);
3487 
3488  auto const rate = transferRate(lesActive, book.out.account);
3489 
3490  const bool bGlobalFreeze = lesActive.isGlobalFrozen (book.out.account) ||
3491  lesActive.isGlobalFrozen (book.in.account);
3492 
3493  while (iLimit-- > 0 && obIterator.nextOffer ())
3494  {
3495 
3496  SLE::pointer sleOffer = obIterator.getCurrentOffer();
3497  if (sleOffer)
3498  {
3499  auto const uOfferOwnerID = sleOffer->getAccountID (sfAccount);
3500  auto const& saTakerGets = sleOffer->getFieldAmount (sfTakerGets);
3501  auto const& saTakerPays = sleOffer->getFieldAmount (sfTakerPays);
3502  STAmount saDirRate = obIterator.getCurrentRate ();
3503  STAmount saOwnerFunds;
3504 
3505  if (book.out.account == uOfferOwnerID)
3506  {
3507  // If offer is selling issuer's own IOUs, it is fully funded.
3508  saOwnerFunds = saTakerGets;
3509  }
3510  else if (bGlobalFreeze)
3511  {
3512  // If either asset is globally frozen, consider all offers
3513  // that aren't ours to be totally unfunded
3514  saOwnerFunds.clear (book.out);
3515  }
3516  else
3517  {
3518  auto umBalanceEntry = umBalance.find (uOfferOwnerID);
3519 
3520  if (umBalanceEntry != umBalance.end ())
3521  {
3522  // Found in running balance table.
3523 
3524  saOwnerFunds = umBalanceEntry->second;
3525  }
3526  else
3527  {
3528  // Did not find balance in table.
3529 
3530  saOwnerFunds = lesActive.accountHolds (
3531  uOfferOwnerID, book.out.currency, book.out.account, fhZERO_IF_FROZEN);
3532 
3533  if (saOwnerFunds.isNegative ())
3534  {
3535  // Treat negative funds as zero.
3536 
3537  saOwnerFunds.zero ();
3538  }
3539  }
3540  }
3541 
3542  Json::Value jvOffer = sleOffer->getJson (JsonOptions::none);
3543 
3544  STAmount saTakerGetsFunded;
3545  STAmount saOwnerFundsLimit = saOwnerFunds;
3546  Rate offerRate = parityRate;
3547 
3548  if (rate != parityRate
3549  // Have a tranfer fee.
3550  && uTakerID != book.out.account
3551  // Not taking offers of own IOUs.
3552  && book.out.account != uOfferOwnerID)
3553  // Offer owner not issuing ownfunds
3554  {
3555  // Need to charge a transfer fee to offer owner.
3556  offerRate = rate;
3557  saOwnerFundsLimit = divide (saOwnerFunds, offerRate);
3558  }
3559 
3560  if (saOwnerFundsLimit >= saTakerGets)
3561  {
3562  // Sufficient funds no shenanigans.
3563  saTakerGetsFunded = saTakerGets;
3564  }
3565  else
3566  {
3567  // Only provide, if not fully funded.
3568  saTakerGetsFunded = saOwnerFundsLimit;
3569 
3570  saTakerGetsFunded.setJson (jvOffer[jss::taker_gets_funded]);
3571 
3572  // TOOD(tom): The result of this expression is not used - what's
3573  // going on here?
3574  std::min (saTakerPays, multiply (
3575  saTakerGetsFunded, saDirRate, saTakerPays.issue ())).setJson (
3576  jvOffer[jss::taker_pays_funded]);
3577  }
3578 
3579  STAmount saOwnerPays = (parityRate == offerRate)
3580  ? saTakerGetsFunded
3581  : std::min (
3582  saOwnerFunds,
3583  multiply (saTakerGetsFunded, offerRate));
3584 
3585  umBalance[uOfferOwnerID] = saOwnerFunds - saOwnerPays;
3586 
3587  if (!saOwnerFunds.isZero () || uOfferOwnerID == uTakerID)
3588  {
3589  // Only provide funded offers and offers of the taker.
3590  Json::Value& jvOf = jvOffers.append (jvOffer);
3591  jvOf[jss::quality] = saDirRate.getText ();
3592  }
3593 
3594  }
3595  }
3596 
3597  // jvResult[jss::marker] = Json::Value(Json::arrayValue);
3598  // jvResult[jss::nodes] = Json::Value(Json::arrayValue);
3599 }
3600 
3601 #endif
3602 
3603 //------------------------------------------------------------------------------
3604 
3606  : InfoSub::Source ("NetworkOPs", parent)
3607 {
3608 }
3609 
3610 //------------------------------------------------------------------------------
3611 
3612 
3614 {
3615  auto now = std::chrono::system_clock::now();
3616 
3617  std::lock_guard lock (mutex_);
3618  ++counters_[static_cast<std::size_t>(om)].transitions;
3619  counters_[static_cast<std::size_t>(mode_)].dur +=
3620  std::chrono::duration_cast<std::chrono::microseconds>(now - start_);
3621 
3622  mode_ = om;
3623  start_ = now;
3624 }
3625 
3628 {
3629  auto [counters, mode, start] = getCounterData();
3630  auto const current = std::chrono::duration_cast<
3632  counters[static_cast<std::size_t>(mode)].dur += current;
3633 
3635 
3636  for (std::size_t i = static_cast<std::size_t>(
3638  i <= static_cast<std::size_t>(OperatingMode::FULL); ++i)
3639  {
3640  ret[states_[i]] = Json::objectValue;
3641  auto& state = ret[states_[i]];
3642  state[jss::transitions] = counters[i].transitions;
3643  state[jss::duration_us] = std::to_string(counters[i].dur.count());
3644  }
3645 
3646  return {ret, std::to_string(current.count())};
3647 }
3648 
3649 //------------------------------------------------------------------------------
3650 
3653  bool standalone, std::size_t minPeerCount, bool startvalid,
3654  JobQueue& job_queue, LedgerMaster& ledgerMaster, Stoppable& parent,
3655  ValidatorKeys const & validatorKeys, boost::asio::io_service& io_svc,
3656  beast::Journal journal, beast::insight::Collector::ptr const& collector)
3657 {
3658  return std::make_unique<NetworkOPsImp> (app, clock, standalone,
3659  minPeerCount, startvalid, job_queue, ledgerMaster, parent,
3660  validatorKeys, io_svc, journal, collector);
3661 }
3662 
3663 } // ripple
ripple::NetworkOPsImp::unsubValidations
bool unsubValidations(std::uint64_t uListener) override
Definition: NetworkOPs.cpp:3180
ripple::NetworkOPsImp::Stats::hook
beast::insight::Hook hook
Definition: NetworkOPs.cpp:683
ripple::STTx::getTxnType
TxType getTxnType() const
Definition: STTx.h:98
ripple::setup_FeeVote
FeeVote::Setup setup_FeeVote(Section const &section)
Build FeeVote::Setup from a config section.
Definition: FeeVoteImpl.cpp:265
ripple::RCLConsensus::prevLedgerID
RCLCxLedger::ID prevLedgerID() const
Definition: RCLConsensus.h:486
ripple::NetworkOPsImp::subValidations
bool subValidations(InfoSub::ref ispListener) override
Definition: NetworkOPs.cpp:3172
ripple::NetworkOPsImp::processHeartbeatTimer
void processHeartbeatTimer()
Definition: NetworkOPs.cpp:831
ripple::NetworkOPs
Provides server functionality for clients.
Definition: NetworkOPs.h:89
ripple::RCLConsensus::phase
ConsensusPhase phase() const
Definition: RCLConsensus.h:459
ripple::NetworkOPsImp::mapComplete
void mapComplete(std::shared_ptr< SHAMap > const &map, bool fromAcquire) override
Definition: NetworkOPs.cpp:1634
ripple::NetworkOPsImp::setClusterTimer
void setClusterTimer()
Definition: NetworkOPs.cpp:801
ripple::Application
Definition: Application.h:85
ripple::transferRate
Rate transferRate(ReadView const &view, AccountID const &issuer)
Definition: View.cpp:338
ripple::TimeKeeper::nowOffset
virtual std::chrono::duration< std::int32_t > nowOffset() const =0
ripple::ClusterNode
Definition: ClusterNode.h:30
ripple::NetworkOPsImp::SubTypes
SubTypes
Definition: NetworkOPs.cpp:630
ripple::NetworkOPsImp::unsubConsensus
bool unsubConsensus(std::uint64_t uListener) override
Definition: NetworkOPs.cpp:3210
ripple::jtTRANSACTION
@ jtTRANSACTION
Definition: Job.h:52
ripple::Transaction::transactionFromSQL
static Transaction::pointer transactionFromSQL(boost::optional< std::uint64_t > const &ledgerSeq, boost::optional< std::string > const &status, Blob const &rawTxn, Application &app)
Definition: Transaction.cpp:83
ripple::Application::getOrderBookDB
virtual OrderBookDB & getOrderBookDB()=0
ripple::NetworkOPsImp::getConsensusLCL
uint256 getConsensusLCL() override
Definition: NetworkOPs.cpp:1615
ripple::RCLCxPeerPos
A peer's signed, proposed position for use in RCLConsensus.
Definition: RCLCxPeerPos.h:42
ripple::HashPrefix::ledgerMaster
@ ledgerMaster
ledger master data for signing
std::lock
T lock(T... args)
ripple::InboundLedgers::getInfo
virtual Json::Value getInfo()=0
ripple::sfLoadFee
const SF_U32 sfLoadFee(access, STI_UINT32, 24, "LoadFee")
Definition: SField.h:361
ripple::NetworkOPsImp::ServerFeeSummary::em
boost::optional< TxQ::Metrics > em
Definition: NetworkOPs.cpp:208
ripple::LoadManager
Manages load sources.
Definition: LoadManager.h:43
ripple::Application::cluster
virtual Cluster & cluster()=0
ripple::NetworkOPsImp::transactionsSQL
std::string transactionsSQL(std::string selection, AccountID const &account, std::int32_t minLedger, std::int32_t maxLedger, bool descending, std::uint32_t offset, int limit, bool binary, bool count, bool bUnlimited)
Definition: NetworkOPs.cpp:2013
ripple::sfIndexNext
const SF_U64 sfIndexNext(access, STI_UINT64, 1, "IndexNext")
Definition: SField.h:379
ripple::NetworkOPsImp::m_journal
beast::Journal m_journal
Definition: NetworkOPs.cpp:602
ripple::LedgerMaster::getPublishedLedger
std::shared_ptr< ReadView const > getPublishedLedger()
Definition: LedgerMaster.cpp:1524
ripple::NetworkOPsImp::sLastEntry
@ sLastEntry
Definition: NetworkOPs.cpp:641
ripple::NetworkOPsImp::pubProposedTransaction
void pubProposedTransaction(std::shared_ptr< ReadView const > const &lpCurrent, std::shared_ptr< STTx const > const &stTxn, TER terResult) override
Definition: NetworkOPs.cpp:2625
ripple::Application::getAcceptedLedgerCache
virtual TaggedCache< uint256, AcceptedLedger > & getAcceptedLedgerCache()=0
std::bind
T bind(T... args)
ripple::NetworkOPs::AccountTxs
std::vector< AccountTx > AccountTxs
Definition: NetworkOPs.h:223
ripple::OpenLedger::current
std::shared_ptr< OpenView const > current() const
Returns a view to the current open ledger.
Definition: OpenLedger.cpp:52
ripple::NetworkOPsImp::TransactionStatus::applied
bool applied
Definition: NetworkOPs.cpp:85
ripple::NetworkOPsImp::mLastFeeSummary
ServerFeeSummary mLastFeeSummary
Definition: NetworkOPs.cpp:646
ripple::ValidatorList::localPublicKey
PublicKey localPublicKey() const
Returns local validator public key.
Definition: ValidatorList.cpp:622
ripple::InboundLedger::Reason::CONSENSUS
@ CONSENSUS
std::string
STL class.
std::shared_ptr< Transaction >
ripple::ConsensusMode::proposing
@ proposing
We are normal participant in consensus and propose our position.
ripple::NetworkOPsImp::heartbeatTimer_
boost::asio::steady_timer heartbeatTimer_
Definition: NetworkOPs.cpp:615
ripple::ManifestCache::getMasterKey
PublicKey getMasterKey(PublicKey const &pk) const
Returns ephemeral signing key's master public key.
Definition: app/misc/impl/Manifest.cpp:301
ripple::RCLConsensus::getJson
Json::Value getJson(bool full) const
Definition: RCLConsensus.cpp:808
ripple::NetworkOPsImp::minPeerCount_
const std::size_t minPeerCount_
Definition: NetworkOPs.cpp:655
ripple::jtCLIENT
@ jtCLIENT
Definition: Job.h:49
ripple::fhZERO_IF_FROZEN
@ fhZERO_IF_FROZEN
Definition: View.h:56
utility
ripple::Rate
Represents a transfer rate.
Definition: Rate.h:37
std::exception
STL class.
ripple::NetworkOPsImp::setStateTimer
void setStateTimer() override
Called to initially start our timers.
Definition: NetworkOPs.cpp:765
ripple::base_uint::isNonZero
bool isNonZero() const
Definition: base_uint.h:430
ripple::Stoppable::stopped
void stopped()
Called by derived classes to indicate that the stoppable has stopped.
Definition: Stoppable.cpp:71
beast::Journal::trace
Stream trace() const
Severity stream access functions.
Definition: Journal.h:287
ripple::STAmount::clear
void clear()
Definition: STAmount.h:222
ripple::NetworkOPsImp::pubValidation
void pubValidation(STValidation::ref val) override
Definition: NetworkOPs.cpp:1887
ripple::AcceptedLedgerTx::getTxn
std::shared_ptr< STTx const > const & getTxn() const
Definition: AcceptedLedgerTx.h:70
ripple::NetworkOPsImp::m_stats
Stats m_stats
Definition: NetworkOPs.cpp:698
ripple::Book::out
Issue out
Definition: Book.h:36
ripple::HashRouter::getFlags
int getFlags(uint256 const &key)
Definition: HashRouter.cpp:84
ripple::make_FeeVote
std::unique_ptr< FeeVote > make_FeeVote(FeeVote::Setup const &setup, beast::Journal journal)
Create an instance of the FeeVote logic.
Definition: FeeVoteImpl.cpp:285
ripple::LedgerMaster::pruneHeldTransactions
std::vector< std::shared_ptr< STTx const > > pruneHeldTransactions(AccountID const &account, std::uint32_t const seq)
Get all the transactions held for a particular account.
Definition: LedgerMaster.cpp:557
ripple::NetworkOPs::txnMetaLedgerType
std::tuple< Blob, Blob, std::uint32_t > txnMetaLedgerType
Definition: NetworkOPs.h:240
ripple::NetworkOPsImp::getTxsAccountB
MetaTxsList getTxsAccountB(AccountID const &account, std::int32_t minLedger, std::int32_t maxLedger, bool forward, std::optional< AccountTxMarker > &marker, int limit, bool bUnlimited) override
Definition: NetworkOPs.cpp:2255
ripple::isTesSuccess
bool isTesSuccess(TER x)
Definition: TER.h:501
ripple::TrustChanges
Changes in trusted nodes after updating validator list.
Definition: ValidatorList.h:68
ripple::Resource::Gossip
Data format for exchanging consumption information across peers.
Definition: Gossip.h:29
ripple::NetworkOPsImp::setAmendmentWarned
void setAmendmentWarned() override
Definition: NetworkOPs.cpp:399
ripple::NetworkOPsImp::pubManifest
void pubManifest(Manifest const &) override
Definition: NetworkOPs.cpp:1718
ripple::Manifest
Definition: Manifest.h:78
ripple::NetworkOPsImp::collect_metrics
void collect_metrics()
Definition: NetworkOPs.cpp:701
ripple::NetworkOPsImp::subPeerStatus
bool subPeerStatus(InfoSub::ref ispListener) override
Definition: NetworkOPs.cpp:3187
std::unordered_set
STL class.
ripple::NetworkOPsImp::mDispatchState
DispatchState mDispatchState
Definition: NetworkOPs.cpp:660
ripple::NetworkOPsImp::DispatchState::none
@ none
Json::arrayValue
@ arrayValue
array value (ordered list)
Definition: json_value.h:44
ripple::NetworkOPs::FailHard::no
@ no
std::pair
ripple::TxQ::apply
std::pair< TER, bool > apply(Application &app, OpenView &view, std::shared_ptr< STTx const > const &tx, ApplyFlags flags, beast::Journal j)
Add a new transaction to the open ledger, hold it in the queue, or reject it.
Definition: TxQ.cpp:617
ripple::Overlay::getJqTransOverflow
virtual std::uint64_t getJqTransOverflow() const =0
ripple::NetworkOPsImp::mSubRTAccount
SubInfoMapType mSubRTAccount
Definition: NetworkOPs.cpp:626
ripple::NetworkOPsImp::amendmentWarned_
std::atomic< bool > amendmentWarned_
Definition: NetworkOPs.cpp:612
ripple::NetworkOPsImp::states_
static const std::array< char const *, 5 > states_
Definition: NetworkOPs.cpp:112
ripple::LedgerMaster
Definition: LedgerMaster.h:60
ripple::ttOFFER_CREATE
@ ttOFFER_CREATE
Definition: TxFormats.h:44
ripple::ConsensusMode::wrongLedger
@ wrongLedger
We have the wrong ledger and are attempting to acquire it.
ripple::convert
void convert(soci::blob &from, std::vector< std::uint8_t > &to)
Definition: SociDB.cpp:150
ripple::LedgerMaster::getValidLedgerIndex
LedgerIndex getValidLedgerIndex()
Definition: LedgerMaster.cpp:223
ripple::Application::getAmendmentTable
virtual AmendmentTable & getAmendmentTable()=0
ripple::NetworkOPsImp::setMode
void setMode(OperatingMode om) override
Definition: NetworkOPs.cpp:1983
ripple::ClusterNode::name
std::string const & name() const
Definition: ClusterNode.h:46
ripple::OpenView
Writable ledger view that accumulates state and tx changes.
Definition: OpenView.h:52
ripple::cdirNext
bool cdirNext(ReadView const &view, uint256 const &uRootIndex, std::shared_ptr< SLE const > &sleNode, unsigned int &uDirEntry, uint256 &uEntryIndex, beast::Journal j)
Definition: View.cpp:472
ripple::NetworkOPsImp::strOperatingMode
std::string strOperatingMode(bool const admin=false) const override
Definition: NetworkOPs.cpp:261
Json::UInt
unsigned int UInt
Definition: json_forwards.h:28
Json::Compact
Decorator for streaming out compact json.
Definition: json_writer.h:277
ripple::getBookBase
uint256 getBookBase(Book const &book)
Definition: Indexes.cpp:67
ripple::NetworkOPsImp::StateAccounting::Counters::dur
std::chrono::microseconds dur
Definition: NetworkOPs.cpp:135
ripple::Manifest::signingKey
PublicKey signingKey
The ephemeral key associated with this manifest.
Definition: Manifest.h:87
ripple::InfoSub
Manages a client's subscription to data feeds.
Definition: InfoSub.h:40
std::vector
STL class.
std::unordered_map::find
T find(T... args)
ripple::Validations::trustChanged
void trustChanged(hash_set< NodeID > const &added, hash_set< NodeID > const &removed)
Update trust status of validations.
Definition: Validations.h:643
ripple::NetworkOPsImp::acceptLedger
std::uint32_t acceptLedger(boost::optional< std::chrono::milliseconds > consensusDelay) override
Accepts the current transaction tree, return the new ledger's sequence.
Definition: NetworkOPs.cpp:3038
ripple::NetworkOPsImp::setNeedNetworkLedger
void setNeedNetworkLedger() override
Definition: NetworkOPs.cpp:369
ripple::NetworkOPsImp::tryRemoveRpcSub
bool tryRemoveRpcSub(std::string const &strUrl) override
Definition: NetworkOPs.cpp:3238
ripple::Manifest::masterKey
PublicKey masterKey
The master key associated with this manifest.
Definition: Manifest.h:84
ripple::accountHolds
STAmount accountHolds(ReadView const &view, AccountID const &account, Currency const &currency, AccountID const &issuer, FreezeHandling zeroIfFrozen, beast::Journal j)
Definition: View.cpp:91
ripple::PublicKey::empty
bool empty() const noexcept
Definition: PublicKey.h:117
ripple::STAmount::getText
std::string getText() const override
Definition: STAmount.cpp:492
ripple::accountTxPage
void accountTxPage(DatabaseCon &connection, AccountIDCache const &idCache, std::function< void(std::uint32_t)> const &onUnsavedLedger, std::function< void(std::uint32_t, std::string const &, Blob const &, Blob const &)> const &onTransaction, AccountID const &account, std::int32_t minLedger, std::int32_t maxLedger, bool forward, std::optional< NetworkOPs::AccountTxMarker > &marker, int limit, bool bAdmin, std::uint32_t page_length)
Definition: AccountTxPaging.cpp:64
ripple::Overlay::getActivePeers
virtual PeerSequence getActivePeers()=0
Returns a sequence representing the current list of peers.
ripple::Overlay::foreach
std::enable_if_t<! std::is_void< typename UnaryFunc::return_type >::value, typename UnaryFunc::return_type > foreach(UnaryFunc f)
Visit every active peer and return a value The functor must:
Definition: Overlay.h:195
ripple::NetworkOPsImp::getHostId
std::string getHostId(bool forAdmin)
Definition: NetworkOPs.cpp:743
ripple::RCLConsensus::gotTxSet
void gotTxSet(NetClock::time_point const &now, RCLTxSet const &txSet)
Definition: RCLConsensus.cpp:836
ripple::NetworkOPsImp::sValidations
@ sValidations
Definition: NetworkOPs.cpp:637
ripple::sfAccount
const SF_Account sfAccount(access, STI_ACCOUNT, 1, "Account")
Definition: SField.h:460
std::chrono::microseconds
ripple::ApplyFlags
ApplyFlags
Definition: ApplyView.h:30
ripple::crypto_prng
csprng_engine & crypto_prng()
The default cryptographically secure PRNG.
Definition: csprng.cpp:111
ripple::LedgerMaster::getValidatedRules
Rules getValidatedRules()
Definition: LedgerMaster.cpp:1509
ripple::Issue::currency
Currency currency
Definition: Issue.h:37
ripple::JobQueue::getJson
Json::Value getJson(int c=0)
Definition: JobQueue.cpp:219
ripple::toBase58
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
Definition: AccountID.cpp:29
ripple::ValidatorList::updateTrusted
TrustChanges updateTrusted(hash_set< NodeID > const &seenValidators)
Update trusted nodes.
Definition: ValidatorList.cpp:901
ripple::NetworkOPsImp::Stats::disconnected_duration
beast::insight::Gauge disconnected_duration
Definition: NetworkOPs.cpp:684
ripple::NetworkOPsImp::StateAccounting::Counters
Definition: NetworkOPs.cpp:130
ripple::sfTakerPays
const SF_Amount sfTakerPays(access, STI_AMOUNT, 4, "TakerPays")
Definition: SField.h:426
std::unordered_map::emplace
T emplace(T... args)
ripple::LedgerMaster::switchLCL
void switchLCL(std::shared_ptr< Ledger const > const &lastClosed)
Definition: LedgerMaster.cpp:485
ripple::HELD
@ HELD
Definition: Transaction.h:50
beast::Journal::warn
Stream warn() const
Definition: Journal.h:302
std::recursive_mutex
STL class.
ripple::keylet::child
Keylet child(uint256 const &key)
Any item that can be in an owner dir.
Definition: Indexes.cpp:213
ripple::NetworkOPsImp::consensusViewChange
void consensusViewChange() override
Definition: NetworkOPs.cpp:1709
std::lock_guard
STL class.
ripple::NetworkOPsImp::accounting_
StateAccounting accounting_
Definition: NetworkOPs.cpp:663
ripple::ConsensusParms::ledgerGRANULARITY
std::chrono::milliseconds ledgerGRANULARITY
How often we check state or change positions.
Definition: ConsensusParms.h:98
ripple::NetworkOPsImp::DispatchState::scheduled
@ scheduled
tuple
ripple::LedgerMaster::getLedgerByHash
std::shared_ptr< Ledger const > getLedgerByHash(uint256 const &hash)
Definition: LedgerMaster.cpp:1677
ripple::RCLConsensus::timerEntry
void timerEntry(NetClock::time_point const &now)
Definition: RCLConsensus.cpp:820
ripple::NetworkOPsImp::apply
void apply(std::unique_lock< std::mutex > &batchLock)
Attempt to apply transactions and post-process based on the results.
Definition: NetworkOPs.cpp:1129
ripple::NetworkOPsImp::m_clock
clock_type & m_clock
Definition: NetworkOPs.cpp:601
ripple::JobQueue::addJob
bool addJob(JobType type, std::string const &name, JobHandler &&jobHandler)
Adds a job to the JobQueue.
Definition: JobQueue.h:156
ripple::NetworkOPsImp::Stats::syncing_transitions
beast::insight::Gauge syncing_transitions
Definition: NetworkOPs.cpp:692
std::function
ripple::LoadFeeTrack::getLoadBase
std::uint32_t getLoadBase() const
Definition: LoadFeeTrack.h:82
ripple::to_string
std::string to_string(ListDisposition disposition)
Definition: ValidatorList.cpp:41
ripple::getQualityNext
uint256 getQualityNext(uint256 const &uBase)
Definition: Indexes.cpp:127
ripple::Application::timeKeeper
virtual TimeKeeper & timeKeeper()=0
ripple::Application::getMasterMutex
virtual MutexType & getMasterMutex()=0
ripple::Application::openLedger
virtual OpenLedger & openLedger()=0
ripple::NetworkOPsImp::pubLedger
void pubLedger(std::shared_ptr< ReadView const > const &lpAccepted) override
Definition: NetworkOPs.cpp:2656
ripple::Cluster::update
bool update(PublicKey const &identity, std::string name, std::uint32_t loadFee=0, NetClock::time_point reportTime=NetClock::time_point{})
Store information about the state of a cluster node.
Definition: Cluster.cpp:59
ripple::NetworkOPsImp::switchLastClosedLedger
void switchLastClosedLedger(std::shared_ptr< Ledger const > const &newLCL)
Definition: NetworkOPs.cpp:1511
ripple::convertBlobsToTxResult
void convertBlobsToTxResult(NetworkOPs::AccountTxs &to, std::uint32_t ledger_index, std::string const &status, Blob const &rawTxn, Blob const &rawMeta, Application &app)
Definition: AccountTxPaging.cpp:33
ripple::tapNONE
@ tapNONE
Definition: ApplyView.h:33
ripple::NetworkOPsImp::doTransactionAsync
void doTransactionAsync(std::shared_ptr< Transaction > transaction, bool bUnlimited, FailHard failtype)
For transactions not submitted by a locally connected client, fire and forget.
Definition: NetworkOPs.cpp:1055
ripple::TxQ::Metrics
Structure returned by TxQ::getMetrics, expressed in reference fee level units.
Definition: TxQ.h:180
ripple::peer_in_set
Select all peers that are in the specified set.
Definition: predicates.h:155
ripple::RCLValidatedLedger
Wraps a ledger instance for use in generic Validations LedgerTrie.
Definition: RCLValidations.h:147
ripple::sfReserveBase
const SF_U32 sfReserveBase(access, STI_UINT32, 31, "ReserveBase")
Definition: SField.h:368
ripple::OpenLedger::accept
void accept(Application &app, Rules const &rules, std::shared_ptr< Ledger const > const &ledger, OrderedTxs const &locals, bool retriesFirst, OrderedTxs &retries, ApplyFlags flags, std::string const &suffix="", modify_type const &f={})
Accept a new ledger.
Definition: OpenLedger.cpp:74
ripple::parityRate
const Rate parityRate(QUALITY_ONE)
A transfer rate signifying a 1:1 exchange.
Definition: Rate.h:110
std::shared_ptr::reset
T reset(T... args)
ripple::NetworkOPsImp::TransactionStatus::result
TER result
Definition: NetworkOPs.cpp:86
ripple::handleNewValidation
bool handleNewValidation(Application &app, STValidation::ref val, std::string const &source)
Handle a new validation.
Definition: RCLValidations.cpp:151
ripple::NetworkOPsImp::getAccountTxs
AccountTxs getAccountTxs(AccountID const &account, std::int32_t minLedger, std::int32_t maxLedger, bool descending, std::uint32_t offset, int limit, bool bUnlimited) override
Definition: NetworkOPs.cpp:2096
ripple::ValidatorKeys
Validator keys and manifest as set in configuration file.
Definition: ValidatorKeys.h:36
ripple::Application::accountIDCache
virtual AccountIDCache const & accountIDCache() const =0
ripple::NetworkOPsImp::mAcquiringLedger
std::shared_ptr< InboundLedger > mAcquiringLedger
Definition: NetworkOPs.cpp:623
std::unordered_map::clear
T clear(T... args)
ripple::Application::getInboundLedgers
virtual InboundLedgers & getInboundLedgers()=0
ripple::Application::getFeeTrack
virtual LoadFeeTrack & getFeeTrack()=0
ripple::base_uint::size
constexpr static std::size_t size()
Definition: base_uint.h:417
ripple::LedgerMaster::getCompleteLedgers
std::string getCompleteLedgers()
Definition: LedgerMaster.cpp:1531
ripple::send_always
Sends a message to all peers.
Definition: predicates.h:31
ripple::NetworkOPsImp::StateAccounting::transitions_
static const Json::StaticString transitions_
Definition: NetworkOPs.cpp:144
ripple::OperatingMode::SYNCING
@ SYNCING
fallen slightly behind
ripple::NetworkOPsImp::processClusterTimer
void processClusterTimer()
Definition: NetworkOPs.cpp:888
ripple::NetworkOPsImp::unsubTransactions
bool unsubTransactions(std::uint64_t uListener) override
Definition: NetworkOPs.cpp:3150
std::unique_lock::unlock
T unlock(T... args)
ripple::Serializer::data
void const * data() const noexcept
Definition: Serializer.h:79
ripple::terQUEUED
@ terQUEUED
Definition: TER.h:203
ripple::NetworkOPsImp::StateAccounting::mutex_
std::mutex mutex_
Definition: NetworkOPs.cpp:140
std::tie
T tie(T... args)
ripple::Resource::Manager::exportConsumers
virtual Gossip exportConsumers()=0
Extract packaged consumer information for export.
ripple::LedgerMaster::peekMutex
std::recursive_mutex & peekMutex()
Definition: LedgerMaster.cpp:1496
ripple::NetworkOPsImp::ServerFeeSummary::loadFactorServer
std::uint32_t loadFactorServer
Definition: NetworkOPs.cpp:205
ripple::divide
STAmount divide(STAmount const &amount, Rate const &rate)
Definition: Rate2.cpp:92
ripple::NetworkOPsImp::~NetworkOPsImp
~NetworkOPsImp() override
Definition: NetworkOPs.cpp:244
ripple::isTerRetry
bool isTerRetry(TER x)
Definition: TER.h:496
ripple::LoadFeeTrack::getRemoteFee
std::uint32_t getRemoteFee() const
Definition: LoadFeeTrack.h:64
ripple::jtBATCH
@ jtBATCH
Definition: Job.h:53
ripple::base_uint
Definition: base_uint.h:65
ripple::make_NetworkOPs
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, Stoppable &parent, ValidatorKeys const &validatorKeys, boost::asio::io_service &io_svc, beast::Journal journal, beast::insight::Collector::ptr const &collector)
Definition: NetworkOPs.cpp:3652
ripple::Manifest::getSignature
boost::optional< Blob > getSignature() const
Returns manifest signature.
Definition: app/misc/impl/Manifest.cpp:218
ripple::INCLUDED
@ INCLUDED
Definition: Transaction.h:47
ripple::RCLConsensus
Manages the generic consensus algorithm for use by the RCL.
Definition: RCLConsensus.h:49
ripple::warnRPC_AMENDMENT_BLOCKED
@ warnRPC_AMENDMENT_BLOCKED
Definition: ErrorCodes.h:148
ripple::RCLConsensus::parms
const ConsensusParms & parms() const
Definition: RCLConsensus.h:505
ripple::NetworkOPsImp::m_statsMutex
std::mutex m_statsMutex
Definition: NetworkOPs.cpp:697
std::chrono::time_point::time_since_epoch
T time_since_epoch(T... args)
ripple::isGlobalFrozen
bool isGlobalFrozen(ReadView const &view, AccountID const &issuer)
Definition: View.cpp:56
ripple::NetworkOPsImp::Stats::syncing_duration
beast::insight::Gauge syncing_duration
Definition: NetworkOPs.cpp:686
ripple::NetworkOPsImp::isAmendmentBlocked
bool isAmendmentBlocked() override
Definition: NetworkOPs.cpp:388
ripple::NetworkOPsImp::addRpcSub
InfoSub::pointer addRpcSub(std::string const &strUrl, InfoSub::ref) override
Definition: NetworkOPs.cpp:3228
ripple::NetworkOPsImp::TransactionStatus::failType
const FailHard failType
Definition: NetworkOPs.cpp:84
Json::Value::append
Value & append(const Value &value)
Append value to array at the end.
Definition: json_value.cpp:907
ripple::NetworkOPsImp::StateAccounting::json
StateCountersJson json() const
Output state counters in JSON format.
Definition: NetworkOPs.cpp:3627
ripple::OperatingMode::DISCONNECTED
@ DISCONNECTED
not ready to process requests
ripple::NetworkOPsImp::TransactionStatus::local
const bool local
Definition: NetworkOPs.cpp:83
ripple::Stoppable
Provides an interface for starting and stopping.
Definition: Stoppable.h:200
ripple::NetworkOPsImp::clearAmendmentWarned
void clearAmendmentWarned() override
Definition: NetworkOPs.cpp:404
ripple::STAmount::setJson
void setJson(Json::Value &) const
Definition: STAmount.cpp:444
ripple::UptimeClock::now
static time_point now()
Definition: UptimeClock.cpp:64
ripple::jtTXN_PROC
@ jtTXN_PROC
Definition: Job.h:70
ripple::OrderBookDB::processTxn
void processTxn(std::shared_ptr< ReadView const > const &ledger, const AcceptedLedgerTx &alTx, Json::Value const &jvObj)
Definition: OrderBookDB.cpp:241
ripple::AcceptedLedgerTx::getMeta
std::shared_ptr< TxMeta > const & getMeta() const
Definition: AcceptedLedgerTx.h:74
ripple::Application::getIOLatency
virtual std::chrono::milliseconds getIOLatency()=0
ripple::Application::getValidationPublicKey
virtual const PublicKey & getValidationPublicKey() const =0
ripple::NetworkOPsImp::getOwnerInfo
Json::Value getOwnerInfo(std::shared_ptr< ReadView const > lpLedger, AccountID const &account) override
Definition: NetworkOPs.cpp:1337
ripple::checkValidity
std::pair< Validity, std::string > checkValidity(HashRouter &router, STTx const &tx, Rules const &rules, Config const &config)
Checks transaction signature and local checks.
Definition: apply.cpp:37
ripple::DatabaseCon::checkoutDb
LockedSociSession checkoutDb()
Definition: DatabaseCon.h:123
ripple::NetworkOPs::MetaTxsList
std::vector< txnMetaLedgerType > MetaTxsList
Definition: NetworkOPs.h:241
ripple::NetworkOPsImp::reportFeeChange
void reportFeeChange() override
Definition: NetworkOPs.cpp:2723
ripple::LoadFeeTrack::getLocalFee
std::uint32_t getLocalFee() const
Definition: LoadFeeTrack.h:70
ripple::base_uint::isZero
bool isZero() const
Definition: base_uint.h:429
ripple::OperatingMode::CONNECTED
@ CONNECTED
convinced we are talking to the network
ripple::OBSOLETE
@ OBSOLETE
Definition: Transaction.h:52
ripple::Application::getLoadManager
virtual LoadManager & getLoadManager()=0
ripple::InfoSub::pointer
std::shared_ptr< InfoSub > pointer
Definition: InfoSub.h:46
Json::objectValue
@ objectValue
object value (collection of name/value pairs).
Definition: json_value.h:45
ripple::XRPAmount::decimalXRP
constexpr double decimalXRP() const
Definition: XRPAmount.h:267
ripple::NetworkOPsImp::hasTXSet
bool hasTXSet(const std::shared_ptr< Peer > &peer, uint256 const &set, protocol::TxSetStatus status)
ripple::Application::getLedgerMaster
virtual LedgerMaster & getLedgerMaster()=0
ripple::InboundLedgers::acquire
virtual std::shared_ptr< Ledger const > acquire(uint256 const &hash, std::uint32_t seq, InboundLedger::Reason)=0
ripple::RCLConsensus::peerProposal
bool peerProposal(NetClock::time_point const &now, RCLCxPeerPos const &newProposal)
Definition: RCLConsensus.cpp:864
ripple::OperatingMode::TRACKING
@ TRACKING
convinced we agree with the network
ripple::NetworkOPsImp::pubValidatedTransaction
void pubValidatedTransaction(std::shared_ptr< ReadView const > const &alAccepted, const AcceptedLedgerTx &alTransaction)
Definition: NetworkOPs.cpp:2799
ripple::STObject::getAccountID
AccountID getAccountID(SField const &field) const
Definition: STObject.cpp:537
ripple::saveLedgerAsync
void saveLedgerAsync(Application &app, std::uint32_t seq)
Definition: AccountTxPaging.cpp:57
ripple::JsonOptions::none
@ none
ripple::NetworkOPsImp::DispatchState
DispatchState
Synchronization states for transaction batches.
Definition: NetworkOPs.cpp:105
ripple::NetworkOPsImp::sServer
@ sServer
Definition: NetworkOPs.cpp:634
ripple::Application::config
virtual Config & config()=0
ripple::peer_in_cluster
Select all peers (except optional excluded) that are in our cluster.
Definition: predicates.h:132
ripple::TERSubset< CanCvtToTER >
ripple::TrustChanges::removed
hash_set< NodeID > removed
Definition: ValidatorList.h:73
ripple::RCLTxSet
Represents a set of transactions in RCLConsensus.
Definition: RCLCxTx.h:65
ripple::sfSigningTime
const SF_U32 sfSigningTime(access, STI_UINT32, 9, "SigningTime")
Definition: SField.h:345
ripple::NetworkOPsImp::endConsensus
void endConsensus() override
Definition: NetworkOPs.cpp:1656
ripple::Overlay::relay
virtual void relay(protocol::TMProposeSet &m, uint256 const &uid)=0
Relay a proposal.
std::unique_lock
STL class.
ripple::NetworkOPsImp::unsubAccount
void unsubAccount(InfoSub::ref ispListener, hash_set< AccountID > const &vnaAccountIDs, bool rt) override
Definition: NetworkOPs.cpp:2979
ripple::Application::nodeIdentity
virtual std::pair< PublicKey, SecretKey > const & nodeIdentity()=0
ripple::LedgerMaster::canBeCurrent
bool canBeCurrent(std::shared_ptr< Ledger const > const &ledger)
Check the sequence number and parent close time of a ledger against our clock and last validated ledg...
Definition: LedgerMaster.cpp:421
ripple::NetworkOPsImp::unsubRTTransactions
bool unsubRTTransactions(std::uint64_t uListener) override
Definition: NetworkOPs.cpp:3165
ripple::Application::getTxQ
virtual TxQ & getTxQ()=0
ripple::LoadFeeTrack
Manages the current fee schedule.
Definition: LoadFeeTrack.h:43
ripple::NetworkOPsImp::getTxsAccount
AccountTxs getTxsAccount(AccountID const &account, std::int32_t minLedger, std::int32_t maxLedger, bool forward, std::optional< AccountTxMarker > &marker, int limit, bool bUnlimited) override
Definition: NetworkOPs.cpp:2215
std::to_string
T to_string(T... args)
ripple::NetworkOPsImp::subManifests
bool subManifests(InfoSub::ref ispListener) override
Definition: NetworkOPs.cpp:3090
ripple::AcceptedLedgerTx
A transaction that is in a closed ledger.
Definition: AcceptedLedgerTx.h:50
ripple::Resource::Gossip::items
std::vector< Item > items
Definition: Gossip.h:42
ripple::set
bool set(T &target, std::string const &name, Section const &section)
Set a value from a configuration Section If the named value is not found or doesn't parse as a T,...
Definition: BasicConfig.h:271
ripple::NetworkOPsImp::TransactionStatus::transaction
const std::shared_ptr< Transaction > transaction
Definition: NetworkOPs.cpp:81
std::array
STL class.
ripple::LedgerMaster::getValidatedLedger
std::shared_ptr< Ledger const > getValidatedLedger()
Definition: LedgerMaster.h:96
ripple::TxQ::getTxRequiredFeeAndSeq
FeeAndSeq getTxRequiredFeeAndSeq(OpenView const &view, std::shared_ptr< STTx const > const &tx) const
Returns minimum required fee for tx and two sequences: first vaild sequence for this account in curre...
Definition: TxQ.cpp:1381
ripple::NetworkOPsImp::ServerFeeSummary
Server fees published on server subscription.
Definition: NetworkOPs.cpp:189
ripple::NetworkOPsImp::transJson
Json::Value transJson(const STTx &stTxn, TER terResult, bool bValidated, std::shared_ptr< ReadView const > const &lpCurrent)
Definition: NetworkOPs.cpp:2747
ripple::NetworkOPsImp::m_localTX
std::unique_ptr< LocalTxs > m_localTX
Definition: NetworkOPs.cpp:604
ripple::NetworkOPsImp::DispatchState::running
@ running
ripple::NetworkOPsImp::StateAccounting::CounterData::start
decltype(start_) start
Definition: NetworkOPs.cpp:179
ripple::getOwnerDirIndex
uint256 getOwnerDirIndex(AccountID const &account)
Definition: Indexes.cpp:89
ripple::ConsensusPhase
ConsensusPhase
Phases of consensus for a single ledger round.
Definition: ConsensusTypes.h:103
ripple::STAmount
Definition: STAmount.h:42
ripple::NetworkOPsImp::StateAccounting::Counters::Counters
Counters()=default
ripple::sfLedgerSequence
const SF_U32 sfLedgerSequence(access, STI_UINT32, 6, "LedgerSequence")
Definition: SField.h:342
beast::Journal::error
Stream error() const
Definition: Journal.h:307
ripple::LedgerMaster::isCompatible
bool isCompatible(ReadView const &, beast::Journal::Stream, char const *reason)
Definition: LedgerMaster.cpp:229
beast::Journal::info
Stream info() const
Definition: Journal.h:297
ripple::NetworkOPsImp::m_job_queue
JobQueue & m_job_queue
Definition: NetworkOPs.cpp:649
std::unordered_map::erase
T erase(T... args)
ripple::BuildInfo::getVersionString
std::string const & getVersionString()
Server version.
Definition: BuildInfo.cpp:58
ripple::Application::logs
virtual Logs & logs()=0
ripple::STTx
Definition: STTx.h:43
ripple::NetworkOPsImp::pubAccountTransaction
void pubAccountTransaction(std::shared_ptr< ReadView const > const &lpCurrent, const AcceptedLedgerTx &alTransaction, bool isAccepted)
Definition: NetworkOPs.cpp:2850
ripple::LedgerMaster::getLedgerBySeq
std::shared_ptr< Ledger const > getLedgerBySeq(std::uint32_t index)
Definition: LedgerMaster.cpp:1641
ripple::RCLConsensus::mode
ConsensusMode mode() const
Definition: RCLConsensus.h:453
ripple::AcceptedLedgerTx::getAffected
boost::container::flat_set< AccountID > const & getAffected() const
Definition: AcceptedLedgerTx.h:80
ripple::NetworkOPsImp::StateAccounting::CounterData::counters
decltype(counters_) counters
Definition: NetworkOPs.cpp:177
ripple::NetworkOPsImp::Stats::tracking_duration
beast::insight::Gauge tracking_duration
Definition: NetworkOPs.cpp:687
ripple::NetworkOPsImp::recvValidation
bool recvValidation(STValidation::ref val, std::string const &source) override
Definition: NetworkOPs.cpp:2292
ripple::warnRPC_UNSUPPORTED_MAJORITY
@ warnRPC_UNSUPPORTED_MAJORITY
Definition: ErrorCodes.h:147
ripple::NetworkOPsImp::subTransactions
bool subTransactions(InfoSub::ref ispListener) override
Definition: NetworkOPs.cpp:3142
ripple::TimeKeeper::closeTime
virtual time_point closeTime() const =0
Returns the close time, in network time.
ripple::ValStatus::current
@ current
This was a new validation and was added.
ripple::Job
Definition: Job.h:83
ripple::ClosureCounter
Definition: ClosureCounter.h:40
ripple::NetworkOPsImp::StateAccounting::counters_
std::array< Counters, 5 > counters_
Definition: NetworkOPs.cpp:139
Json::Value::isMember
bool isMember(const char *key) const
Return true if the object has a member named key.
Definition: json_value.cpp:961
ripple::NetworkOPsImp::unsubLedger
bool unsubLedger(std::uint64_t uListener) override
Definition: NetworkOPs.cpp:3083
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:60
ripple::NetworkOPsImp::isAmendmentWarned
bool isAmendmentWarned() override
Definition: NetworkOPs.cpp:394
ripple::Application::getValidations
virtual RCLValidations & getValidations()=0
std::uint32_t
std::condition_variable::wait
T wait(T... args)
ripple::NetworkOPsImp::needNetworkLedger_
std::atomic< bool > needNetworkLedger_
Definition: NetworkOPs.cpp:610
ripple::temBAD_SIGNATURE
@ temBAD_SIGNATURE
Definition: TER.h:103
ripple::HashRouter::shouldRelay
boost::optional< std::set< PeerShortID > > shouldRelay(uint256 const &key)
Determines whether the hashed item should be relayed.
Definition: HashRouter.cpp:107
ripple::LedgerMaster::addHeldTransaction
void addHeldTransaction(std::shared_ptr< Transaction > const &trans)
Definition: LedgerMaster.cpp:410
ripple::Manifest::getMasterSignature
Blob getMasterSignature() const
Returns manifest master key signature.
Definition: app/misc/impl/Manifest.cpp:228
std::atomic< OperatingMode >
ripple::NetworkOPsImp::ServerFeeSummary::ServerFeeSummary
ServerFeeSummary()=default
ripple::NetworkOPsImp::StateAccounting::mode_
OperatingMode mode_
Definition: NetworkOPs.cpp:138
std::map
STL class.
ripple::ClosureCounter::wrap
boost::optional< Wrapper< Closure > > wrap(Closure &&closure)
Wrap the passed closure with a reference counter.
Definition: ClosureCounter.h:176
ripple::NetworkOPsImp::NetworkOPsImp
NetworkOPsImp(Application &app, NetworkOPs::clock_type &clock, bool standalone, std::size_t minPeerCount, bool start_valid, JobQueue &job_queue, LedgerMaster &ledgerMaster, Stoppable &parent, ValidatorKeys const &validatorKeys, boost::asio::io_service &io_svc, beast::Journal journal, beast::insight::Collector::ptr const &collector)
Definition: NetworkOPs.cpp:213
ripple::sfIndexes
const SF_Vec256 sfIndexes(access, STI_VECTOR256, 1, "Indexes", SField::sMD_Never)
Definition: SField.h:473
ripple::LoadFeeTrack::getClusterFee
std::uint32_t getClusterFee() const
Definition: LoadFeeTrack.h:76
ripple::NetworkOPs::NetworkOPs
NetworkOPs(Stoppable &parent)
Definition: NetworkOPs.cpp:3605
ripple::amountFromQuality
STAmount amountFromQuality(std::uint64_t rate)
Definition: STAmount.cpp:729
ripple::NetworkOPsImp::getAccountTxsB
MetaTxsList getAccountTxsB(AccountID const &account, std::int32_t minLedger, std::int32_t maxLedger, bool descending, std::uint32_t offset, int limit, bool bUnlimited) override
Definition: NetworkOPs.cpp:2165
ripple::OrderBookDB::makeBookListeners
BookListeners::pointer makeBookListeners(Book const &)
Definition: OrderBookDB.cpp:211
ripple::NetworkOPs::FailHard
FailHard
Definition: NetworkOPs.h:98
ripple::TxQ::processClosedLedger
void processClosedLedger(Application &app, ReadView const &view, bool timeLeap)
Update fee metrics and clean up the queue in preparation for the next ledger.
Definition: TxQ.cpp:1168
ripple::NetworkOPsImp::subAccount
void subAccount(InfoSub::ref ispListener, hash_set< AccountID > const &vnaAccountIDs, bool rt) override
Definition: NetworkOPs.cpp:2943
ripple::NetworkOPsImp::m_standalone
const bool m_standalone
Definition: NetworkOPs.cpp:652
ripple::ReadView::read
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
ripple::LedgerMaster::getCurrentLedger
std::shared_ptr< ReadView const > getCurrentLedger()
Definition: LedgerMaster.cpp:1503
Json::Int
int Int
Definition: json_forwards.h:27
ripple::NetworkOPsImp::Stats
Definition: NetworkOPs.cpp:666
ripple::AcceptedLedgerTx::getResult
TER getResult() const
Definition: AcceptedLedgerTx.h:93
ripple::NetworkOPs::AccountTxMarker
Definition: NetworkOPs.h:215
ripple::STTx::getJson
Json::Value getJson(JsonOptions options) const override
Definition: STTx.cpp:202
beast::abstract_clock< std::chrono::steady_clock >
ripple::NetworkOPsImp::StateAccounting::CounterData::mode
decltype(mode_) mode
Definition: NetworkOPs.cpp:178
ripple::NetworkOPsImp::StateAccounting::CounterData
Definition: NetworkOPs.cpp:176
ripple::accountFunds
STAmount accountFunds(ReadView const &view, AccountID const &id, STAmount const &saDefault, FreezeHandling freezeHandling, beast::Journal j)
Definition: View.cpp:133
ripple::NetworkOPsImp::mStreamMaps
std::array< SubMapType, SubTypes::sLastEntry+1 > mStreamMaps
Definition: NetworkOPs.cpp:644
Json::Value::UInt
Json::UInt UInt
Definition: json_value.h:149
ripple::NetworkOPsImp::TransactionStatus
Transaction with input flags and results to be applied in batches.
Definition: NetworkOPs.cpp:78
ripple::Application::validators
virtual ValidatorList & validators()=0
beast::insight::Gauge
A metric for measuring an integral value.
Definition: Gauge.h:39
ripple::NetworkOPsImp::transactionBatch
void transactionBatch()
Apply transactions in batches.
Definition: NetworkOPs.cpp:1116
ripple::NetworkOPsImp::isNeedNetworkLedger
bool isNeedNetworkLedger() override
Definition: NetworkOPs.cpp:377
ripple::LoadManager::resetDeadlockDetector
void resetDeadlockDetector()
Reset the deadlock detection timer.
Definition: LoadManager.cpp:67
ripple::NetworkOPsImp::ServerFeeSummary::operator!=
bool operator!=(ServerFeeSummary const &b) const
Definition: NetworkOPs.cpp:1768
ripple::NetworkOPsImp::TransactionStatus::TransactionStatus
TransactionStatus(std::shared_ptr< Transaction > t, bool a, bool l, FailHard f)
Definition: NetworkOPs.cpp:88
ripple::NetworkOPsImp::setStandAlone
void setStandAlone() override
Definition: NetworkOPs.cpp:359
ripple::JobQueue
A pool of threads to perform work.
Definition: JobQueue.h:56
ripple::NetworkOPsImp::mSubLock
std::recursive_mutex mSubLock
Definition: NetworkOPs.cpp:606
ripple::NetworkOPsImp::onStop
void onStop() override
Override called when the stop notification is issued.
Definition: NetworkOPs.cpp:543
ripple::NetworkOPsImp::ServerFeeSummary::operator==
bool operator==(ServerFeeSummary const &b) const
Definition: NetworkOPs.cpp:200
ripple::NetworkOPsImp::StateAccounting::start_
std::chrono::system_clock::time_point start_
Definition: NetworkOPs.cpp:141
ripple::multiply
STAmount multiply(STAmount const &amount, Rate const &rate)
Definition: Rate2.cpp:37
std::min
T min(T... args)
ripple::OrderBookDB::getBookListeners
BookListeners::pointer getBookListeners(Book const &)
Definition: OrderBookDB.cpp:227
ripple::Overlay::size
virtual std::size_t size()=0
Returns the number of active peers.
ripple::Serializer
Definition: Serializer.h:43
ripple::Manifest::sequence
std::uint32_t sequence
The sequence number of this manifest.
Definition: Manifest.h:90
ripple::Application::getResourceManager
virtual Resource::Manager & getResourceManager()=0
ripple::LedgerMaster::getFetchPackCacheSize
std::size_t getFetchPackCacheSize() const
Definition: LedgerMaster.cpp:2157
ripple::getJson
Json::Value getJson(LedgerFill const &fill)
Return a new Json::Value representing the ledger with given options.
Definition: LedgerToJson.cpp:272
ripple::NetworkOPsImp::sConsensusPhase
@ sConsensusPhase
Definition: NetworkOPs.cpp:639
ripple::NetworkOPsImp::mMutex
std::mutex mMutex
Definition: NetworkOPs.cpp:659
ripple::NetworkOPsImp::Stats::tracking_transitions
beast::insight::Gauge tracking_transitions
Definition: NetworkOPs.cpp:693
ripple::LedgerMaster::getValidatedLedgerAge
std::chrono::seconds getValidatedLedgerAge()
Definition: LedgerMaster.cpp:276
ripple::LedgerMaster::getClosedLedger
std::shared_ptr< Ledger const > getClosedLedger()
Definition: LedgerMaster.h:89
ripple::NetworkOPsImp::Stats::connected_transitions
beast::insight::Gauge connected_transitions
Definition: NetworkOPs.cpp:691
ripple::NetworkOPsImp::clusterTimer_
boost::asio::steady_timer clusterTimer_
Definition: NetworkOPs.cpp:616
ripple::perf::PerfLog::countersJson
virtual Json::Value countersJson() const =0
Render performance counters in Json.
ripple::NetworkOPsImp::mTransactions
std::vector< TransactionStatus > mTransactions
Definition: NetworkOPs.cpp:661
ripple::ReadView
A view into a ledger.
Definition: ReadView.h:186
ripple::NetworkOPsImp::reportConsensusStateChange
void reportConsensusStateChange(ConsensusPhase phase)
Definition: NetworkOPs.cpp:2738
std::vector::emplace_back
T emplace_back(T... args)
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::transResultInfo
bool transResultInfo(TER code, std::string &token, std::string &text)
Definition: TER.cpp:169
ripple::NetworkOPsImp::unsubServer
bool unsubServer(std::uint64_t uListener) override
Definition: NetworkOPs.cpp:3135
ripple::RCLConsensus::prevRoundTime
std::chrono::milliseconds prevRoundTime() const
Get duration of the previous round.
Definition: RCLConsensus.h:446
ripple::ltRIPPLE_STATE
@ ltRIPPLE_STATE
Definition: LedgerFormats.h:67
ripple::sterilize
std::shared_ptr< STTx const > sterilize(STTx const &stx)
Sterilize a transaction.
Definition: STTx.cpp:516
ripple::Config::features
std::unordered_set< uint256, beast::uhash<> > features
Definition: Config.h:183
ripple::NetworkOPsImp::Stats::Stats
Stats(Handler const &handler, beast::insight::Collector::ptr const &collector)
Definition: NetworkOPs.cpp:669
ripple::NetworkOPsImp::setHeartbeatTimer
void setHeartbeatTimer()
Definition: NetworkOPs.cpp:771
ripple::Application::journal
virtual beast::Journal journal(std::string const &name)=0
ripple::Application::validatorManifests
virtual ManifestCache & validatorManifests()=0
ripple::NetworkOPsImp::getLocalTxCount
std::size_t getLocalTxCount() override
Definition: NetworkOPs.cpp:424
ripple::Serializer::size
std::size_t size() const noexcept
Definition: Serializer.h:73
ripple::LoadFeeTrack::getLoadFactor
std::uint32_t getLoadFactor() const
Definition: LoadFeeTrack.h:87
ripple::NetworkOPsImp::getTXMap
std::shared_ptr< SHAMap > getTXMap(uint256 const &hash)
ripple::NetworkOPsImp::getLedgerFetchInfo
Json::Value getLedgerFetchInfo() override
Definition: NetworkOPs.cpp:2620
ripple::tapUNLIMITED
@ tapUNLIMITED
Definition: ApplyView.h:49
ripple::send_if_not
send_if_not_pred< Predicate > send_if_not(std::shared_ptr< Message > const &m, Predicate const &f)
Helper function to aid in type deduction.
Definition: predicates.h:102
ripple::NetworkOPsImp::sManifests
@ sManifests
Definition: NetworkOPs.cpp:633
ripple::NetworkOPsImp::StateAccounting::StateAccounting
StateAccounting()
Definition: NetworkOPs.cpp:148
ripple::INVALID
@ INVALID
Definition: Transaction.h:46
ripple::Validity::Valid
@ Valid
Signature and local checks are good / passed.
ripple::NetworkOPsImp::pubServer
void pubServer()
Definition: NetworkOPs.cpp:1795
ripple::base_uint::begin
iterator begin()
Definition: base_uint.h:106
ripple::tefPAST_SEQ
@ tefPAST_SEQ
Definition: TER.h:155
ripple::NetworkOPsImp::unsubBook
bool unsubBook(std::uint64_t uListener, Book const &) override
Definition: NetworkOPs.cpp:3030
ripple::TransactionMaster::canonicalize
void canonicalize(std::shared_ptr< Transaction > *pTransaction)
Definition: TransactionMaster.cpp:123
std::chrono::duration_cast
T duration_cast(T... args)
ripple::NetworkOPsImp::sTransactions
@ sTransactions
Definition: NetworkOPs.cpp:635
ripple::NetworkOPsImp::mSubAccount
SubInfoMapType mSubAccount
Definition: NetworkOPs.cpp:625
ripple::AcceptedLedgerTx::isApplied
bool isApplied() const
Definition: AcceptedLedgerTx.h:102
ripple::NetworkOPsImp::clearNeedNetworkLedger
void clearNeedNetworkLedger() override
Definition: NetworkOPs.cpp:373
ripple::sfReserveIncrement
const SF_U32 sfReserveIncrement(access, STI_UINT32, 32, "ReserveIncrement")
Definition: SField.h:369
beast::rngfill
void rngfill(void *buffer, std::size_t bytes, Generator &g)
Definition: rngfill.h:32
ripple::STAmount::issue
Issue const & issue() const
Definition: STAmount.h:156
Json::StaticString
Lightweight wrapper to tag static string.
Definition: json_value.h:62
ripple::NetworkOPsImp::TransactionStatus::admin
const bool admin
Definition: NetworkOPs.cpp:82
std
STL namespace.
ripple::NetworkOPsImp::checkLastClosedLedger
bool checkLastClosedLedger(const Overlay::PeerSequence &, uint256 &networkClosed)
Definition: NetworkOPs.cpp:1407
std::unordered_set::insert
T insert(T... args)
ripple::NetworkOPsImp::strOperatingMode
std::string strOperatingMode(OperatingMode const mode, bool const admin) const override
Definition: NetworkOPs.cpp:936
ripple::NetworkOPsImp::getBookPage
void getBookPage(std::shared_ptr< ReadView const > &lpLedger, Book const &, AccountID const &uTakerID, const bool bProof, unsigned int iLimit, Json::Value const &jvMarker, Json::Value &jvResult) override
Definition: NetworkOPs.cpp:3262
ripple::NetworkOPsImp::ServerFeeSummary::baseFee
XRPAmount baseFee
Definition: NetworkOPs.cpp:207
ripple::RPC::insertDeliveredAmount
void insertDeliveredAmount(Json::Value &meta, ReadView const &, std::shared_ptr< STTx const > const &serializedTx, TxMeta const &)
Add a delivered_amount field to the meta input/output parameter.
Definition: DeliveredAmount.cpp:133
ripple::NetworkOPsImp::pubPeerStatus
void pubPeerStatus(std::function< Json::Value(void)> const &) override
Definition: NetworkOPs.cpp:1954
ripple::NetworkOPsImp::mCond
std::condition_variable mCond
Definition: NetworkOPs.cpp:658
ripple::NetworkOPsImp::isFull
bool isFull() override
Definition: NetworkOPs.cpp:381
ripple::LedgerMaster::getCurrentLedgerIndex
LedgerIndex getCurrentLedgerIndex()
Definition: LedgerMaster.cpp:217
ripple::NetworkOPsImp::subLedger
bool subLedger(InfoSub::ref ispListener, Json::Value &jvResult) override
Definition: NetworkOPs.cpp:3056
std::condition_variable
ripple::NetworkOPsImp::Stats::full_transitions
beast::insight::Gauge full_transitions
Definition: NetworkOPs.cpp:694
ripple::stateNames
static const std::array< char const *, 5 > stateNames
Definition: NetworkOPs.cpp:724
ripple::NetworkOPsImp::sLedger
@ sLedger
Definition: NetworkOPs.cpp:632
ripple::TimeKeeper::now
virtual time_point now() const override=0
Returns the estimate of wall time, in network time.
ripple::NetworkOPsImp::mConsensus
RCLConsensus mConsensus
Definition: NetworkOPs.cpp:618
ripple::sfCloseTime
const SF_U32 sfCloseTime(access, STI_UINT32, 7, "CloseTime")
Definition: SField.h:343
ripple::RCLConsensus::prevProposers
std::size_t prevProposers() const
Get the number of proposing peers that participated in the previous round.
Definition: RCLConsensus.h:433
ripple::Application::overlay
virtual Overlay & overlay()=0
ripple::NetworkOPsImp::sPeerStatus
@ sPeerStatus
Definition: NetworkOPs.cpp:638
ripple::InfoSub::Source::Source
Source(char const *name, Stoppable &parent)
Definition: InfoSub.cpp:38
std::chrono::milliseconds::count
T count(T... args)
ripple::NetworkOPsImp::mMode
std::atomic< OperatingMode > mMode
Definition: NetworkOPs.cpp:608
ripple::NetworkOPsImp::unsubManifests
bool unsubManifests(std::uint64_t uListener) override
Definition: NetworkOPs.cpp:3098
ripple::tapFAIL_HARD
@ tapFAIL_HARD
Definition: ApplyView.h:37
ripple::TrustChanges::added
hash_set< NodeID > added
Definition: ValidatorList.h:72
ripple::sfTakerGets
const SF_Amount sfTakerGets(access, STI_AMOUNT, 5, "TakerGets")
Definition: SField.h:427
ripple::NetworkOPsImp::amendmentBlocked_
std::atomic< bool > amendmentBlocked_
Definition: NetworkOPs.cpp:611
ripple::NetworkOPsImp::submitTransaction
void submitTransaction(std::shared_ptr< STTx const > const &) override
Definition: NetworkOPs.cpp:955
std::string::empty
T empty(T... args)
ripple::OperatingMode
OperatingMode
Specifies the mode under which the server believes it's operating.
Definition: NetworkOPs.h:68
ripple::fhIGNORE_FREEZE
@ fhIGNORE_FREEZE
Definition: View.h:55
ripple::InboundLedgers::clearFailures
virtual void clearFailures()=0
ripple::TokenType::NodePublic
@ NodePublic
ripple::RCLCxPeerPos::suppressionID
uint256 const & suppressionID() const
Unique id used by hash router to suppress duplicates.
Definition: RCLCxPeerPos.h:88
ripple::ClosureCounter::join
void join(char const *name, std::chrono::milliseconds wait, beast::Journal j)
Returns once all counted in-flight closures are destroyed.
Definition: ClosureCounter.h:148
ripple::NetworkOPsImp::mLastConsensusPhase
ConsensusPhase mLastConsensusPhase
Definition: NetworkOPs.cpp:620
ripple::NetworkOPsImp::updateLocalTx
void updateLocalTx(ReadView const &view) override
Definition: NetworkOPs.cpp:420
std::optional
mutex
ripple::NetworkOPsImp::sRTTransactions
@ sRTTransactions
Definition: NetworkOPs.cpp:636
ripple::NetworkOPs::FailHard::yes
@ yes
beast::Journal::debug
Stream debug() const
Definition: Journal.h:292
ripple::AcceptedLedgerTx::getJson
Json::Value getJson() const
Definition: AcceptedLedgerTx.h:111
ripple::NetworkOPsImp::pubConsensus
void pubConsensus(ConsensusPhase phase)
Definition: NetworkOPs.cpp:1859
std::size_t
ripple::Cluster::for_each
void for_each(std::function< void(ClusterNode const &)> func) const
Invokes the callback once for every cluster node.
Definition: Cluster.cpp:88
ripple::NetworkOPsImp::subRTTransactions
bool subRTTransactions(InfoSub::ref ispListener) override
Definition: NetworkOPs.cpp:3157
ripple::Book
Specifies an order book.
Definition: Book.h:32
ripple::ClusterNode::getReportTime
NetClock::time_point getReportTime() const
Definition: ClusterNode.h:56
ripple::NetworkOPsImp::Stats::disconnected_transitions
beast::insight::Gauge disconnected_transitions
Definition: NetworkOPs.cpp:690
ripple::NetworkOPsImp::StateAccounting::dur_
static const Json::StaticString dur_
Definition: NetworkOPs.cpp:145
ripple::AmendmentTable::firstUnsupportedExpected
virtual boost::optional< NetClock::time_point > firstUnsupportedExpected()=0
ripple::strHex
std::string strHex(FwdIt begin, FwdIt end)
Definition: strHex.h:70
std::unordered_map::end
T end(T... args)
ripple::mulDiv
std::pair< bool, Dest > mulDiv(Source1 value, Dest mul, Source2 div)
Definition: FeeUnits.h:487
ripple::NetworkOPsImp::getServerInfo
Json::Value getServerInfo(bool human, bool admin, bool counters) override
Definition: NetworkOPs.cpp:2306
ripple::perf::PerfLog::currentJson
virtual Json::Value currentJson() const =0
Render currently executing jobs and RPC calls and durations in Json.
ripple::NetworkOPsImp::m_ledgerMaster
LedgerMaster & m_ledgerMaster
Definition: NetworkOPs.cpp:622
ripple::NetworkOPsImp::subServer
bool subServer(InfoSub::ref ispListener, Json::Value &jvResult, bool admin) override
Definition: NetworkOPs.cpp:3105
ripple::Validations::getCurrentNodeIDs
auto getCurrentNodeIDs() -> hash_set< NodeID >
Get the set of node ids associated with current validations.
Definition: Validations.h:867
ripple::ltDIR_NODE
@ ltDIR_NODE
Directory node.
Definition: LedgerFormats.h:65
ripple::ltOFFER
@ ltOFFER
Definition: LedgerFormats.h:73
ripple::sfAmendments
const SF_Vec256 sfAmendments(access, STI_VECTOR256, 3, "Amendments")
Definition: SField.h:475
std::numeric_limits::max
T max(T... args)
ripple::Validity::SigBad
@ SigBad
Signature is bad. Didn't do local checks.
ripple::ValidatorList::expires
boost::optional< TimeKeeper::time_point > expires() const
Return the time when the validator list will expire.
Definition: ValidatorList.cpp:664
ripple::RCLConsensus::validating
bool validating() const
Whether we are validating consensus ledgers.
Definition: RCLConsensus.h:425
ripple::make_LocalTxs
std::unique_ptr< LocalTxs > make_LocalTxs()
Definition: LocalTxs.cpp:175
ripple::TxQ::getMetrics
Metrics getMetrics(OpenView const &view) const
Returns fee metrics in reference fee level units.
Definition: TxQ.cpp:1358
ripple::NetworkOPsImp::doTransactionSync
void doTransactionSync(std::shared_ptr< Transaction > transaction, bool bUnlimited, FailHard failType)
For transactions submitted directly by a client, apply batch of transactions and wait for this transa...
Definition: NetworkOPs.cpp:1078
ripple::NetworkOPsImp::StateAccounting::getCounterData
CounterData getCounterData() const
Definition: NetworkOPs.cpp:182
ripple::sfBaseFee
const SF_U64 sfBaseFee(access, STI_UINT64, 5, "BaseFee")
Definition: SField.h:383
ripple::JobQueue::makeLoadEvent
std::unique_ptr< LoadEvent > makeLoadEvent(JobType t, std::string const &name)
Return a scoped LoadEvent.
Definition: JobQueue.cpp:181
ripple::NetworkOPsImp::Stats::full_duration
beast::insight::Gauge full_duration
Definition: NetworkOPs.cpp:688
ripple::Application::getPerfLog
virtual perf::PerfLog & getPerfLog()=0
ripple::send_if
send_if_pred< Predicate > send_if(std::shared_ptr< Message > const &m, Predicate const &f)
Helper function to aid in type deduction.
Definition: predicates.h:71
ripple::Overlay::getPeerDisconnect
virtual std::uint64_t getPeerDisconnect() const =0
ripple::OrderedTxs
CanonicalTXSet OrderedTxs
Definition: OpenLedger.h:44
ripple::NetworkOPsImp::subBook
bool subBook(InfoSub::ref ispListener, Book const &) override
Definition: NetworkOPs.cpp:3021
ripple::NetworkOPsImp::subConsensus
bool subConsensus(InfoSub::ref ispListener) override
Definition: NetworkOPs.cpp:3202
ripple::pendSaveValidated
bool pendSaveValidated(Application &app, std::shared_ptr< Ledger const > const &ledger, bool isSynchronous, bool isCurrent)
Save, or arrange to save, a fully-validated ledger Returns false on error.
Definition: Ledger.cpp:979
ripple::NetworkOPsImp::getConsensusInfo
Json::Value getConsensusInfo() override
Definition: NetworkOPs.cpp:2301
ripple::ltACCOUNT_ROOT
@ ltACCOUNT_ROOT
Definition: LedgerFormats.h:54
ripple::keylet::offer
static const offer_t offer
Definition: Indexes.h:191
ripple::NetworkOPsImp::Stats::connected_duration
beast::insight::Gauge connected_duration
Definition: NetworkOPs.cpp:685
ripple::ValidatorList::count
std::size_t count() const
Return the number of configured validator list sites.
Definition: ValidatorList.cpp:657
ripple::NetworkOPsImp::waitHandlerCounter_
ClosureCounter< void, boost::system::error_code const & > waitHandlerCounter_
Definition: NetworkOPs.cpp:614
std::unique_ptr
STL class.
ripple::NetworkOPsImp
Definition: NetworkOPs.cpp:71
ripple::NetworkOPsImp::StateAccounting::mode
void mode(OperatingMode om)
Record state transition.
Definition: NetworkOPs.cpp:3613
std::unordered_map
STL class.
ripple::NetworkOPsImp::StateAccounting::states_
static const std::array< Json::StaticString const, 5 > states_
Definition: NetworkOPs.cpp:143
ripple::Overlay::networkID
virtual boost::optional< std::uint32_t > networkID() const =0
Returns the ID of the network this server is configured for, if any.
ripple::RFC1751::getWordFromBlob
static std::string getWordFromBlob(void const *blob, size_t bytes)
Chooses a single dictionary word from the data.
Definition: RFC1751.cpp:482
ripple::NetworkOPsImp::unsubAccountInternal
void unsubAccountInternal(std::uint64_t seq, hash_set< AccountID > const &vnaAccountIDs, bool rt) override
Definition: NetworkOPs.cpp:2994
ripple::ReadView::succ
virtual boost::optional< key_type > succ(key_type const &key, boost::optional< key_type > const &last=boost::none) const =0
Return the key of the next state item.
ripple::tesSUCCESS
@ tesSUCCESS
Definition: TER.h:219
ripple::NetworkOPsImp::StateAccounting
State accounting records two attributes for each possible server state: 1) Amount of time spent in ea...
Definition: NetworkOPs.cpp:128
beast::insight::Hook
A reference to a handler for performing polled collection.
Definition: Hook.h:31
ripple::getQuality
std::uint64_t getQuality(uint256 const &uBase)
Definition: Indexes.cpp:135
ripple::Overlay::getPeerDisconnectCharges
virtual std::uint64_t getPeerDisconnectCharges() const =0
std::condition_variable::notify_all
T notify_all(T... args)
ripple::Application::getHashRouter
virtual HashRouter & getHashRouter()=0
ripple::OpenLedger::modify
bool modify(modify_type const &f)
Modify the open ledger.
Definition: OpenLedger.cpp:59
ripple::NetworkOPsImp::StateAccounting::Counters::transitions
std::uint32_t transitions
Definition: NetworkOPs.cpp:134
ripple::STObject::getFieldAmount
STAmount const & getFieldAmount(SField const &field) const
Definition: STObject.cpp:549
ripple::NetworkOPsImp::unsubPeerStatus
bool unsubPeerStatus(std::uint64_t uListener) override
Definition: NetworkOPs.cpp:3195
ripple::NetworkOPsImp::app_
Application & app_
Definition: NetworkOPs.cpp:600
ripple::HashRouter::setFlags
bool setFlags(uint256 const &key, int flags)
Set the flags on a hash.
Definition: HashRouter.cpp:91
ripple::isTemMalformed
bool isTemMalformed(TER x)
Definition: TER.h:486
ripple::trunc32
static std::uint32_t trunc32(std::uint64_t v)
Definition: NetworkOPs.cpp:1787
ripple::XRPAmount::jsonClipped
Json::Value jsonClipped() const
Definition: XRPAmount.h:223
ripple::Book::in
Issue in
Definition: Book.h:35
ripple::NetworkOPsImp::getOperatingMode
OperatingMode getOperatingMode() const override
Definition: NetworkOPs.cpp:253
ripple::Issue::account
AccountID account
Definition: Issue.h:38
std::ref
T ref(T... args)
ripple::ClusterNode::identity
PublicKey const & identity() const
Definition: ClusterNode.h:62
ripple::NetworkOPsImp::mRpcSubMap
subRpcMapType mRpcSubMap
Definition: NetworkOPs.cpp:628
ripple::ValidatorList::quorum
std::size_t quorum() const
Get quorum value for current trusted key set.
Definition: ValidatorList.h:340
Json::Value
Represents a JSON value.
Definition: json_value.h:141
ripple::keylet::page
Keylet page(uint256 const &key, std::uint64_t index)
A page in a directory.
Definition: Indexes.cpp:324
ripple::TimeKeeper::closeOffset
virtual std::chrono::duration< std::int32_t > closeOffset() const =0
ripple::NetworkOPsImp::findRpcSub
InfoSub::pointer findRpcSub(std::string const &strUrl) override
Definition: NetworkOPs.cpp:3216
beast::insight::Gauge::set
void set(value_type value) const
Set the value on the gauge.
Definition: Gauge.h:68
ripple::NetworkOPsImp::ServerFeeSummary::loadBaseServer
std::uint32_t loadBaseServer
Definition: NetworkOPs.cpp:206
ripple::NetworkOPsImp::processTrustedProposal
void processTrustedProposal(RCLCxPeerPos proposal, std::shared_ptr< protocol::TMProposeSet > set) override
Definition: NetworkOPs.cpp:1620
ripple::Application::getTxnDB
virtual DatabaseCon & getTxnDB()=0
ripple::XRPAmount
Definition: XRPAmount.h:46
ripple::NetworkOPsImp::clearLedgerFetch
void clearLedgerFetch() override
Definition: NetworkOPs.cpp:2615
ripple::AccountIDCache::toBase58
std::string toBase58(AccountID const &) const
Return ripple::toBase58 for the AccountID.
Definition: AccountID.cpp:199
ripple::RCLConsensus::simulate
void simulate(NetClock::time_point const &now, boost::optional< std::chrono::milliseconds > consensusDelay)
Definition: RCLConsensus.cpp:855
ripple::ClusterNode::getLoadFee
std::uint32_t getLoadFee() const
Definition: ClusterNode.h:51
ripple::RCLConsensus::startRound
void startRound(NetClock::time_point const &now, RCLCxLedger::ID const &prevLgrId, RCLCxLedger const &prevLgr, hash_set< NodeID > const &nowUntrusted)
Definition: RCLConsensus.cpp:956
ripple::test::jtx::rate
Json::Value rate(Account const &account, double multiplier)
Set a transfer rate.
Definition: rate.cpp:30
ripple::cdirFirst
bool cdirFirst(ReadView const &view, uint256 const &uRootIndex, std::shared_ptr< SLE const > &sleNode, unsigned int &uDirEntry, uint256 &uEntryIndex, beast::Journal j)
Definition: View.cpp:458
ripple::Application::getMasterTransaction
virtual TransactionMaster & getMasterTransaction()=0
ripple::NetworkOPsImp::beginConsensus
bool beginConsensus(uint256 const &networkClosed) override
Definition: NetworkOPs.cpp:1563
ripple::NetworkOPsImp::setAmendmentBlocked
void setAmendmentBlocked() override
Definition: NetworkOPs.cpp:1401
ripple::NetworkOPsImp::processTransaction
void processTransaction(std::shared_ptr< Transaction > &transaction, bool bUnlimited, bool bLocal, FailHard failType) override
Process transactions as they arrive from the network or which are submitted by clients.
Definition: NetworkOPs.cpp:1010
beast
Definition: base_uint.h:582
string
ripple::OperatingMode::FULL
@ FULL
we have the ledger and can even validate
std::chrono::system_clock::now
T now(T... args)