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