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