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 txCur = e.transaction->getSTransaction();
1369  for (auto const& tx : m_ledgerMaster.pruneHeldTransactions(
1370  txCur->getAccountID(sfAccount),
1371  txCur->getSequence() + 1))
1372  {
1373  std::string reason;
1374  auto const trans = sterilize(*tx);
1375  auto t = std::make_shared<Transaction>(trans, reason, app_);
1376  submit_held.emplace_back(t, false, false, FailHard::no);
1377  t->setApplying();
1378  }
1379  }
1380  else if (e.result == tefPAST_SEQ)
1381  {
1382  // duplicate or conflict
1383  JLOG(m_journal.info()) << "Transaction is obsolete";
1384  e.transaction->setStatus(OBSOLETE);
1385  }
1386  else if (e.result == terQUEUED)
1387  {
1388  JLOG(m_journal.debug())
1389  << "Transaction is likely to claim a"
1390  << " fee, but is queued until fee drops";
1391 
1392  e.transaction->setStatus(HELD);
1393  // Add to held transactions, because it could get
1394  // kicked out of the queue, and this will try to
1395  // put it back.
1396  m_ledgerMaster.addHeldTransaction(e.transaction);
1397  e.transaction->setQueued();
1398  e.transaction->setKept();
1399  }
1400  else if (isTerRetry(e.result))
1401  {
1402  if (e.failType != FailHard::yes)
1403  {
1404  // transaction should be held
1405  JLOG(m_journal.debug())
1406  << "Transaction should be held: " << e.result;
1407  e.transaction->setStatus(HELD);
1408  m_ledgerMaster.addHeldTransaction(e.transaction);
1409  e.transaction->setKept();
1410  }
1411  }
1412  else
1413  {
1414  JLOG(m_journal.debug())
1415  << "Status other than success " << e.result;
1416  e.transaction->setStatus(INVALID);
1417  }
1418 
1419  auto const enforceFailHard =
1420  e.failType == FailHard::yes && !isTesSuccess(e.result);
1421 
1422  if (addLocal && !enforceFailHard)
1423  {
1424  m_localTX->push_back(
1426  e.transaction->getSTransaction());
1427  e.transaction->setKept();
1428  }
1429 
1430  if ((e.applied ||
1431  ((mMode != OperatingMode::FULL) &&
1432  (e.failType != FailHard::yes) && e.local) ||
1433  (e.result == terQUEUED)) &&
1434  !enforceFailHard)
1435  {
1436  auto const toSkip =
1437  app_.getHashRouter().shouldRelay(e.transaction->getID());
1438 
1439  if (toSkip)
1440  {
1441  protocol::TMTransaction tx;
1442  Serializer s;
1443 
1444  e.transaction->getSTransaction()->add(s);
1445  tx.set_rawtransaction(s.data(), s.size());
1446  tx.set_status(protocol::tsCURRENT);
1447  tx.set_receivetimestamp(
1448  app_.timeKeeper().now().time_since_epoch().count());
1449  tx.set_deferred(e.result == terQUEUED);
1450  // FIXME: This should be when we received it
1452  std::make_shared<Message>(tx, protocol::mtTRANSACTION),
1453  peer_in_set(*toSkip)));
1454  e.transaction->setBroadcast();
1455  }
1456  }
1457 
1458  if (validatedLedgerIndex)
1459  {
1460  auto [fee, accountSeq, availableSeq] =
1462  *newOL, e.transaction->getSTransaction());
1463  e.transaction->setCurrentLedgerState(
1464  *validatedLedgerIndex, fee, accountSeq, availableSeq);
1465  }
1466  }
1467  }
1468 
1469  batchLock.lock();
1470 
1471  for (TransactionStatus& e : transactions)
1472  e.transaction->clearApplying();
1473 
1474  if (!submit_held.empty())
1475  {
1476  if (mTransactions.empty())
1477  mTransactions.swap(submit_held);
1478  else
1479  for (auto& e : submit_held)
1480  mTransactions.push_back(std::move(e));
1481  }
1482 
1483  mCond.notify_all();
1484 
1486 }
1487 
1488 //
1489 // Owner functions
1490 //
1491 
1495  AccountID const& account)
1496 {
1497  Json::Value jvObjects(Json::objectValue);
1498  auto root = keylet::ownerDir(account);
1499  auto sleNode = lpLedger->read(keylet::page(root));
1500  if (sleNode)
1501  {
1502  std::uint64_t uNodeDir;
1503 
1504  do
1505  {
1506  for (auto const& uDirEntry : sleNode->getFieldV256(sfIndexes))
1507  {
1508  auto sleCur = lpLedger->read(keylet::child(uDirEntry));
1509  assert(sleCur);
1510 
1511  switch (sleCur->getType())
1512  {
1513  case ltOFFER:
1514  if (!jvObjects.isMember(jss::offers))
1515  jvObjects[jss::offers] =
1517 
1518  jvObjects[jss::offers].append(
1519  sleCur->getJson(JsonOptions::none));
1520  break;
1521 
1522  case ltRIPPLE_STATE:
1523  if (!jvObjects.isMember(jss::ripple_lines))
1524  {
1525  jvObjects[jss::ripple_lines] =
1527  }
1528 
1529  jvObjects[jss::ripple_lines].append(
1530  sleCur->getJson(JsonOptions::none));
1531  break;
1532 
1533  case ltACCOUNT_ROOT:
1534  case ltDIR_NODE:
1535  default:
1536  assert(false);
1537  break;
1538  }
1539  }
1540 
1541  uNodeDir = sleNode->getFieldU64(sfIndexNext);
1542 
1543  if (uNodeDir)
1544  {
1545  sleNode = lpLedger->read(keylet::page(root, uNodeDir));
1546  assert(sleNode);
1547  }
1548  } while (uNodeDir);
1549  }
1550 
1551  return jvObjects;
1552 }
1553 
1554 //
1555 // Other
1556 //
1557 
1558 void
1560 {
1561  amendmentBlocked_ = true;
1563 }
1564 
1565 bool
1567  const Overlay::PeerSequence& peerList,
1568  uint256& networkClosed)
1569 {
1570  // Returns true if there's an *abnormal* ledger issue, normal changing in
1571  // TRACKING mode should return false. Do we have sufficient validations for
1572  // our last closed ledger? Or do sufficient nodes agree? And do we have no
1573  // better ledger available? If so, we are either tracking or full.
1574 
1575  JLOG(m_journal.trace()) << "NetworkOPsImp::checkLastClosedLedger";
1576 
1577  auto const ourClosed = m_ledgerMaster.getClosedLedger();
1578 
1579  if (!ourClosed)
1580  return false;
1581 
1582  uint256 closedLedger = ourClosed->info().hash;
1583  uint256 prevClosedLedger = ourClosed->info().parentHash;
1584  JLOG(m_journal.trace()) << "OurClosed: " << closedLedger;
1585  JLOG(m_journal.trace()) << "PrevClosed: " << prevClosedLedger;
1586 
1587  //-------------------------------------------------------------------------
1588  // Determine preferred last closed ledger
1589 
1590  auto& validations = app_.getValidations();
1591  JLOG(m_journal.debug())
1592  << "ValidationTrie " << Json::Compact(validations.getJsonTrie());
1593 
1594  // Will rely on peer LCL if no trusted validations exist
1596  peerCounts[closedLedger] = 0;
1598  peerCounts[closedLedger]++;
1599 
1600  for (auto& peer : peerList)
1601  {
1602  uint256 peerLedger = peer->getClosedLedgerHash();
1603 
1604  if (peerLedger.isNonZero())
1605  ++peerCounts[peerLedger];
1606  }
1607 
1608  for (auto const& it : peerCounts)
1609  JLOG(m_journal.debug()) << "L: " << it.first << " n=" << it.second;
1610 
1611  uint256 preferredLCL = validations.getPreferredLCL(
1612  RCLValidatedLedger{ourClosed, validations.adaptor().journal()},
1614  peerCounts);
1615 
1616  bool switchLedgers = preferredLCL != closedLedger;
1617  if (switchLedgers)
1618  closedLedger = preferredLCL;
1619  //-------------------------------------------------------------------------
1620  if (switchLedgers && (closedLedger == prevClosedLedger))
1621  {
1622  // don't switch to our own previous ledger
1623  JLOG(m_journal.info()) << "We won't switch to our own previous ledger";
1624  networkClosed = ourClosed->info().hash;
1625  switchLedgers = false;
1626  }
1627  else
1628  networkClosed = closedLedger;
1629 
1630  if (!switchLedgers)
1631  return false;
1632 
1633  auto consensus = m_ledgerMaster.getLedgerByHash(closedLedger);
1634 
1635  if (!consensus)
1636  consensus = app_.getInboundLedgers().acquire(
1637  closedLedger, 0, InboundLedger::Reason::CONSENSUS);
1638 
1639  if (consensus &&
1640  (!m_ledgerMaster.canBeCurrent(consensus) ||
1642  *consensus, m_journal.debug(), "Not switching")))
1643  {
1644  // Don't switch to a ledger not on the validated chain
1645  // or with an invalid close time or sequence
1646  networkClosed = ourClosed->info().hash;
1647  return false;
1648  }
1649 
1650  JLOG(m_journal.warn()) << "We are not running on the consensus ledger";
1651  JLOG(m_journal.info()) << "Our LCL: " << getJson(*ourClosed);
1652  JLOG(m_journal.info()) << "Net LCL " << closedLedger;
1653 
1655  {
1657  }
1658 
1659  if (consensus)
1660  {
1661  // FIXME: If this rewinds the ledger sequence, or has the same
1662  // sequence, we should update the status on any stored transactions
1663  // in the invalidated ledgers.
1664  switchLastClosedLedger(consensus);
1665  }
1666 
1667  return true;
1668 }
1669 
1670 void
1672  std::shared_ptr<Ledger const> const& newLCL)
1673 {
1674  // set the newLCL as our last closed ledger -- this is abnormal code
1675  JLOG(m_journal.error())
1676  << "JUMP last closed ledger to " << newLCL->info().hash;
1677 
1679 
1680  // Update fee computations.
1681  app_.getTxQ().processClosedLedger(app_, *newLCL, true);
1682 
1683  // Caller must own master lock
1684  {
1685  // Apply tx in old open ledger to new
1686  // open ledger. Then apply local tx.
1687 
1688  auto retries = m_localTX->getTxSet();
1689  auto const lastVal = app_.getLedgerMaster().getValidatedLedger();
1690  boost::optional<Rules> rules;
1691  if (lastVal)
1692  rules.emplace(*lastVal, app_.config().features);
1693  else
1694  rules.emplace(app_.config().features);
1696  app_,
1697  *rules,
1698  newLCL,
1699  OrderedTxs({}),
1700  false,
1701  retries,
1702  tapNONE,
1703  "jump",
1704  [&](OpenView& view, beast::Journal j) {
1705  // Stuff the ledger with transactions from the queue.
1706  return app_.getTxQ().accept(app_, view);
1707  });
1708  }
1709 
1710  m_ledgerMaster.switchLCL(newLCL);
1711 
1712  protocol::TMStatusChange s;
1713  s.set_newevent(protocol::neSWITCHED_LEDGER);
1714  s.set_ledgerseq(newLCL->info().seq);
1715  s.set_networktime(app_.timeKeeper().now().time_since_epoch().count());
1716  s.set_ledgerhashprevious(
1717  newLCL->info().parentHash.begin(), newLCL->info().parentHash.size());
1718  s.set_ledgerhash(newLCL->info().hash.begin(), newLCL->info().hash.size());
1719 
1720  app_.overlay().foreach(
1721  send_always(std::make_shared<Message>(s, protocol::mtSTATUS_CHANGE)));
1722 }
1723 
1724 bool
1726 {
1727  assert(networkClosed.isNonZero());
1728 
1729  auto closingInfo = m_ledgerMaster.getCurrentLedger()->info();
1730 
1731  JLOG(m_journal.info()) << "Consensus time for #" << closingInfo.seq
1732  << " with LCL " << closingInfo.parentHash;
1733 
1734  auto prevLedger = m_ledgerMaster.getLedgerByHash(closingInfo.parentHash);
1735 
1736  if (!prevLedger)
1737  {
1738  // this shouldn't happen unless we jump ledgers
1739  if (mMode == OperatingMode::FULL)
1740  {
1741  JLOG(m_journal.warn()) << "Don't have LCL, going to tracking";
1743  }
1744 
1745  return false;
1746  }
1747 
1748  assert(prevLedger->info().hash == closingInfo.parentHash);
1749  assert(
1750  closingInfo.parentHash ==
1751  m_ledgerMaster.getClosedLedger()->info().hash);
1752 
1753  if (prevLedger->rules().enabled(featureNegativeUNL))
1754  app_.validators().setNegativeUNL(prevLedger->negativeUNL());
1755  TrustChanges const changes = app_.validators().updateTrusted(
1757 
1758  if (!changes.added.empty() || !changes.removed.empty())
1759  app_.getValidations().trustChanged(changes.added, changes.removed);
1760 
1763  networkClosed,
1764  prevLedger,
1765  changes.removed,
1766  changes.added);
1767 
1768  const ConsensusPhase currPhase = mConsensus.phase();
1769  if (mLastConsensusPhase != currPhase)
1770  {
1771  reportConsensusStateChange(currPhase);
1772  mLastConsensusPhase = currPhase;
1773  }
1774 
1775  JLOG(m_journal.debug()) << "Initiating consensus engine";
1776  return true;
1777 }
1778 
1779 uint256
1781 {
1782  return mConsensus.prevLedgerID();
1783 }
1784 
1785 bool
1787 {
1788  return mConsensus.peerProposal(app_.timeKeeper().closeTime(), peerPos);
1789 }
1790 
1791 void
1793 {
1794  // We now have an additional transaction set
1795  // either created locally during the consensus process
1796  // or acquired from a peer
1797 
1798  // Inform peers we have this set
1799  protocol::TMHaveTransactionSet msg;
1800  msg.set_hash(map->getHash().as_uint256().begin(), 256 / 8);
1801  msg.set_status(protocol::tsHAVE);
1802  app_.overlay().foreach(
1803  send_always(std::make_shared<Message>(msg, protocol::mtHAVE_SET)));
1804 
1805  // We acquired it because consensus asked us to
1806  if (fromAcquire)
1808 }
1809 
1810 void
1812 {
1813  uint256 deadLedger = m_ledgerMaster.getClosedLedger()->info().parentHash;
1814 
1815  for (auto const& it : app_.overlay().getActivePeers())
1816  {
1817  if (it && (it->getClosedLedgerHash() == deadLedger))
1818  {
1819  JLOG(m_journal.trace()) << "Killing obsolete peer status";
1820  it->cycleStatus();
1821  }
1822  }
1823 
1824  uint256 networkClosed;
1825  bool ledgerChange =
1826  checkLastClosedLedger(app_.overlay().getActivePeers(), networkClosed);
1827 
1828  if (networkClosed.isZero())
1829  return;
1830 
1831  // WRITEME: Unless we are in FULL and in the process of doing a consensus,
1832  // we must count how many nodes share our LCL, how many nodes disagree with
1833  // our LCL, and how many validations our LCL has. We also want to check
1834  // timing to make sure there shouldn't be a newer LCL. We need this
1835  // information to do the next three tests.
1836 
1837  if (((mMode == OperatingMode::CONNECTED) ||
1838  (mMode == OperatingMode::SYNCING)) &&
1839  !ledgerChange)
1840  {
1841  // Count number of peers that agree with us and UNL nodes whose
1842  // validations we have for LCL. If the ledger is good enough, go to
1843  // TRACKING - TODO
1844  if (!needNetworkLedger_)
1846  }
1847 
1848  if (((mMode == OperatingMode::CONNECTED) ||
1850  !ledgerChange)
1851  {
1852  // check if the ledger is good enough to go to FULL
1853  // Note: Do not go to FULL if we don't have the previous ledger
1854  // check if the ledger is bad enough to go to CONNECTE D -- TODO
1856  if (app_.timeKeeper().now() < (current->info().parentCloseTime +
1857  2 * current->info().closeTimeResolution))
1858  {
1860  }
1861  }
1862 
1863  beginConsensus(networkClosed);
1864 }
1865 
1866 void
1868 {
1870  {
1872  }
1873 }
1874 
1875 void
1877 {
1878  // VFALCO consider std::shared_mutex
1880 
1881  if (!mStreamMaps[sManifests].empty())
1882  {
1884 
1885  jvObj[jss::type] = "manifestReceived";
1886  jvObj[jss::master_key] = toBase58(TokenType::NodePublic, mo.masterKey);
1887  if (!mo.signingKey.empty())
1888  jvObj[jss::signing_key] =
1890  jvObj[jss::seq] = Json::UInt(mo.sequence);
1891  if (auto sig = mo.getSignature())
1892  jvObj[jss::signature] = strHex(*sig);
1893  jvObj[jss::master_signature] = strHex(mo.getMasterSignature());
1894 
1895  for (auto i = mStreamMaps[sManifests].begin();
1896  i != mStreamMaps[sManifests].end();)
1897  {
1898  if (auto p = i->second.lock())
1899  {
1900  p->send(jvObj, true);
1901  ++i;
1902  }
1903  else
1904  {
1905  i = mStreamMaps[sManifests].erase(i);
1906  }
1907  }
1908  }
1909 }
1910 
1912  XRPAmount fee,
1913  TxQ::Metrics&& escalationMetrics,
1914  LoadFeeTrack const& loadFeeTrack)
1915  : loadFactorServer{loadFeeTrack.getLoadFactor()}
1916  , loadBaseServer{loadFeeTrack.getLoadBase()}
1917  , baseFee{fee}
1918  , em{std::move(escalationMetrics)}
1919 {
1920 }
1921 
1922 bool
1924  NetworkOPsImp::ServerFeeSummary const& b) const
1925 {
1926  if (loadFactorServer != b.loadFactorServer ||
1927  loadBaseServer != b.loadBaseServer || baseFee != b.baseFee ||
1928  em.is_initialized() != b.em.is_initialized())
1929  return true;
1930 
1931  if (em && b.em)
1932  {
1933  return (
1934  em->minProcessingFeeLevel != b.em->minProcessingFeeLevel ||
1935  em->openLedgerFeeLevel != b.em->openLedgerFeeLevel ||
1936  em->referenceFeeLevel != b.em->referenceFeeLevel);
1937  }
1938 
1939  return false;
1940 }
1941 
1942 // Need to cap to uint64 to uint32 due to JSON limitations
1943 static std::uint32_t
1945 {
1947 
1948  return std::min(max32, v);
1949 };
1950 
1951 void
1953 {
1954  // VFALCO TODO Don't hold the lock across calls to send...make a copy of the
1955  // list into a local array while holding the lock then release
1956  // the lock and call send on everyone.
1957  //
1959 
1960  if (!mStreamMaps[sServer].empty())
1961  {
1963 
1964  ServerFeeSummary f{
1965  app_.openLedger().current()->fees().base,
1967  app_.getFeeTrack()};
1968 
1969  jvObj[jss::type] = "serverStatus";
1970  jvObj[jss::server_status] = strOperatingMode();
1971  jvObj[jss::load_base] = f.loadBaseServer;
1972  jvObj[jss::load_factor_server] = f.loadFactorServer;
1973  jvObj[jss::base_fee] = f.baseFee.jsonClipped();
1974 
1975  if (f.em)
1976  {
1977  auto const loadFactor = std::max(
1978  safe_cast<std::uint64_t>(f.loadFactorServer),
1979  mulDiv(
1980  f.em->openLedgerFeeLevel,
1981  f.loadBaseServer,
1982  f.em->referenceFeeLevel)
1983  .second);
1984 
1985  jvObj[jss::load_factor] = trunc32(loadFactor);
1986  jvObj[jss::load_factor_fee_escalation] =
1987  f.em->openLedgerFeeLevel.jsonClipped();
1988  jvObj[jss::load_factor_fee_queue] =
1989  f.em->minProcessingFeeLevel.jsonClipped();
1990  jvObj[jss::load_factor_fee_reference] =
1991  f.em->referenceFeeLevel.jsonClipped();
1992  }
1993  else
1994  jvObj[jss::load_factor] = f.loadFactorServer;
1995 
1996  mLastFeeSummary = f;
1997 
1998  for (auto i = mStreamMaps[sServer].begin();
1999  i != mStreamMaps[sServer].end();)
2000  {
2001  InfoSub::pointer p = i->second.lock();
2002 
2003  // VFALCO TODO research the possibility of using thread queues and
2004  // linearizing the deletion of subscribers with the
2005  // sending of JSON data.
2006  if (p)
2007  {
2008  p->send(jvObj, true);
2009  ++i;
2010  }
2011  else
2012  {
2013  i = mStreamMaps[sServer].erase(i);
2014  }
2015  }
2016  }
2017 }
2018 
2019 void
2021 {
2023 
2024  auto& streamMap = mStreamMaps[sConsensusPhase];
2025  if (!streamMap.empty())
2026  {
2028  jvObj[jss::type] = "consensusPhase";
2029  jvObj[jss::consensus] = to_string(phase);
2030 
2031  for (auto i = streamMap.begin(); i != streamMap.end();)
2032  {
2033  if (auto p = i->second.lock())
2034  {
2035  p->send(jvObj, true);
2036  ++i;
2037  }
2038  else
2039  {
2040  i = streamMap.erase(i);
2041  }
2042  }
2043  }
2044 }
2045 
2046 void
2048 {
2049  // VFALCO consider std::shared_mutex
2051 
2052  if (!mStreamMaps[sValidations].empty())
2053  {
2055 
2056  auto const signerPublic = val->getSignerPublic();
2057 
2058  jvObj[jss::type] = "validationReceived";
2059  jvObj[jss::validation_public_key] =
2060  toBase58(TokenType::NodePublic, signerPublic);
2061  jvObj[jss::ledger_hash] = to_string(val->getLedgerHash());
2062  jvObj[jss::signature] = strHex(val->getSignature());
2063  jvObj[jss::full] = val->isFull();
2064  jvObj[jss::flags] = val->getFlags();
2065  jvObj[jss::signing_time] = *(*val)[~sfSigningTime];
2066 
2067  auto const masterKey =
2068  app_.validatorManifests().getMasterKey(signerPublic);
2069 
2070  if (masterKey != signerPublic)
2071  jvObj[jss::master_key] = toBase58(TokenType::NodePublic, masterKey);
2072 
2073  if (auto const seq = (*val)[~sfLedgerSequence])
2074  jvObj[jss::ledger_index] = to_string(*seq);
2075 
2076  if (val->isFieldPresent(sfAmendments))
2077  {
2078  jvObj[jss::amendments] = Json::Value(Json::arrayValue);
2079  for (auto const& amendment : val->getFieldV256(sfAmendments))
2080  jvObj[jss::amendments].append(to_string(amendment));
2081  }
2082 
2083  if (auto const closeTime = (*val)[~sfCloseTime])
2084  jvObj[jss::close_time] = *closeTime;
2085 
2086  if (auto const loadFee = (*val)[~sfLoadFee])
2087  jvObj[jss::load_fee] = *loadFee;
2088 
2089  if (auto const baseFee = (*val)[~sfBaseFee])
2090  jvObj[jss::base_fee] = static_cast<double>(*baseFee);
2091 
2092  if (auto const reserveBase = (*val)[~sfReserveBase])
2093  jvObj[jss::reserve_base] = *reserveBase;
2094 
2095  if (auto const reserveInc = (*val)[~sfReserveIncrement])
2096  jvObj[jss::reserve_inc] = *reserveInc;
2097 
2098  for (auto i = mStreamMaps[sValidations].begin();
2099  i != mStreamMaps[sValidations].end();)
2100  {
2101  if (auto p = i->second.lock())
2102  {
2103  p->send(jvObj, true);
2104  ++i;
2105  }
2106  else
2107  {
2108  i = mStreamMaps[sValidations].erase(i);
2109  }
2110  }
2111  }
2112 }
2113 
2114 void
2116 {
2118 
2119  if (!mStreamMaps[sPeerStatus].empty())
2120  {
2121  Json::Value jvObj(func());
2122 
2123  jvObj[jss::type] = "peerStatusChange";
2124 
2125  for (auto i = mStreamMaps[sPeerStatus].begin();
2126  i != mStreamMaps[sPeerStatus].end();)
2127  {
2128  InfoSub::pointer p = i->second.lock();
2129 
2130  if (p)
2131  {
2132  p->send(jvObj, true);
2133  ++i;
2134  }
2135  else
2136  {
2137  i = mStreamMaps[sPeerStatus].erase(i);
2138  }
2139  }
2140  }
2141 }
2142 
2143 void
2145 {
2146  using namespace std::chrono_literals;
2147  if (om == OperatingMode::CONNECTED)
2148  {
2151  }
2152  else if (om == OperatingMode::SYNCING)
2153  {
2154  if (app_.getLedgerMaster().getValidatedLedgerAge() >= 1min)
2156  }
2157 
2160 
2161  if (mMode == om)
2162  return;
2163 
2164  mMode = om;
2165 
2166  accounting_.mode(om);
2167 
2168  JLOG(m_journal.info()) << "STATE->" << strOperatingMode();
2169  pubServer();
2170 }
2171 
2174  std::string selection,
2175  AccountID const& account,
2176  std::int32_t minLedger,
2177  std::int32_t maxLedger,
2178  bool descending,
2179  std::uint32_t offset,
2180  int limit,
2181  bool binary,
2182  bool count,
2183  bool bUnlimited)
2184 {
2185  std::uint32_t NONBINARY_PAGE_LENGTH = 200;
2186  std::uint32_t BINARY_PAGE_LENGTH = 500;
2187 
2188  std::uint32_t numberOfResults;
2189 
2190  if (count)
2191  {
2192  numberOfResults = 1000000000;
2193  }
2194  else if (limit < 0)
2195  {
2196  numberOfResults = binary ? BINARY_PAGE_LENGTH : NONBINARY_PAGE_LENGTH;
2197  }
2198  else if (!bUnlimited)
2199  {
2200  numberOfResults = std::min(
2201  binary ? BINARY_PAGE_LENGTH : NONBINARY_PAGE_LENGTH,
2202  static_cast<std::uint32_t>(limit));
2203  }
2204  else
2205  {
2206  numberOfResults = limit;
2207  }
2208 
2209  std::string maxClause = "";
2210  std::string minClause = "";
2211 
2212  if (maxLedger != -1)
2213  {
2214  maxClause = boost::str(
2215  boost::format("AND AccountTransactions.LedgerSeq <= '%u'") %
2216  maxLedger);
2217  }
2218 
2219  if (minLedger != -1)
2220  {
2221  minClause = boost::str(
2222  boost::format("AND AccountTransactions.LedgerSeq >= '%u'") %
2223  minLedger);
2224  }
2225 
2226  std::string sql;
2227 
2228  if (count)
2229  sql = boost::str(
2230  boost::format("SELECT %s FROM AccountTransactions "
2231  "WHERE Account = '%s' %s %s LIMIT %u, %u;") %
2232  selection % app_.accountIDCache().toBase58(account) % maxClause %
2233  minClause % beast::lexicalCastThrow<std::string>(offset) %
2234  beast::lexicalCastThrow<std::string>(numberOfResults));
2235  else
2236  sql = boost::str(
2237  boost::format(
2238  "SELECT %s FROM "
2239  "AccountTransactions INNER JOIN Transactions "
2240  "ON Transactions.TransID = AccountTransactions.TransID "
2241  "WHERE Account = '%s' %s %s "
2242  "ORDER BY AccountTransactions.LedgerSeq %s, "
2243  "AccountTransactions.TxnSeq %s, AccountTransactions.TransID %s "
2244  "LIMIT %u, %u;") %
2245  selection % app_.accountIDCache().toBase58(account) % maxClause %
2246  minClause % (descending ? "DESC" : "ASC") %
2247  (descending ? "DESC" : "ASC") % (descending ? "DESC" : "ASC") %
2248  beast::lexicalCastThrow<std::string>(offset) %
2249  beast::lexicalCastThrow<std::string>(numberOfResults));
2250  JLOG(m_journal.trace()) << "txSQL query: " << sql;
2251  return sql;
2252 }
2253 
2256  AccountID const& account,
2257  std::int32_t minLedger,
2258  std::int32_t maxLedger,
2259  bool descending,
2260  std::uint32_t offset,
2261  int limit,
2262  bool bUnlimited)
2263 {
2264  // can be called with no locks
2265  AccountTxs ret;
2266 
2268  "AccountTransactions.LedgerSeq,Status,RawTxn,TxnMeta",
2269  account,
2270  minLedger,
2271  maxLedger,
2272  descending,
2273  offset,
2274  limit,
2275  false,
2276  false,
2277  bUnlimited);
2278 
2279  {
2280  auto db = app_.getTxnDB().checkoutDb();
2281 
2282  boost::optional<std::uint64_t> ledgerSeq;
2283  boost::optional<std::string> status;
2284  soci::blob sociTxnBlob(*db), sociTxnMetaBlob(*db);
2285  soci::indicator rti, tmi;
2286  Blob rawTxn, txnMeta;
2287 
2288  soci::statement st =
2289  (db->prepare << sql,
2290  soci::into(ledgerSeq),
2291  soci::into(status),
2292  soci::into(sociTxnBlob, rti),
2293  soci::into(sociTxnMetaBlob, tmi));
2294 
2295  st.execute();
2296  while (st.fetch())
2297  {
2298  if (soci::i_ok == rti)
2299  convert(sociTxnBlob, rawTxn);
2300  else
2301  rawTxn.clear();
2302 
2303  if (soci::i_ok == tmi)
2304  convert(sociTxnMetaBlob, txnMeta);
2305  else
2306  txnMeta.clear();
2307 
2309  ledgerSeq, status, rawTxn, app_);
2310 
2311  if (txnMeta.empty())
2312  { // Work around a bug that could leave the metadata missing
2313  auto const seq =
2314  rangeCheckedCast<std::uint32_t>(ledgerSeq.value_or(0));
2315 
2316  JLOG(m_journal.warn())
2317  << "Recovering ledger " << seq << ", txn " << txn->getID();
2318 
2319  if (auto l = m_ledgerMaster.getLedgerBySeq(seq))
2320  pendSaveValidated(app_, l, false, false);
2321  }
2322 
2323  if (txn)
2324  ret.emplace_back(
2325  txn,
2326  std::make_shared<TxMeta>(
2327  txn->getID(), txn->getLedger(), txnMeta));
2328  }
2329  }
2330 
2331  return ret;
2332 }
2333 
2336  AccountID const& account,
2337  std::int32_t minLedger,
2338  std::int32_t maxLedger,
2339  bool descending,
2340  std::uint32_t offset,
2341  int limit,
2342  bool bUnlimited)
2343 {
2344  // can be called with no locks
2346 
2348  "AccountTransactions.LedgerSeq,Status,RawTxn,TxnMeta",
2349  account,
2350  minLedger,
2351  maxLedger,
2352  descending,
2353  offset,
2354  limit,
2355  true /*binary*/,
2356  false,
2357  bUnlimited);
2358 
2359  {
2360  auto db = app_.getTxnDB().checkoutDb();
2361 
2362  boost::optional<std::uint64_t> ledgerSeq;
2363  boost::optional<std::string> status;
2364  soci::blob sociTxnBlob(*db), sociTxnMetaBlob(*db);
2365  soci::indicator rti, tmi;
2366 
2367  soci::statement st =
2368  (db->prepare << sql,
2369  soci::into(ledgerSeq),
2370  soci::into(status),
2371  soci::into(sociTxnBlob, rti),
2372  soci::into(sociTxnMetaBlob, tmi));
2373 
2374  st.execute();
2375  while (st.fetch())
2376  {
2377  Blob rawTxn;
2378  if (soci::i_ok == rti)
2379  convert(sociTxnBlob, rawTxn);
2380  Blob txnMeta;
2381  if (soci::i_ok == tmi)
2382  convert(sociTxnMetaBlob, txnMeta);
2383 
2384  auto const seq =
2385  rangeCheckedCast<std::uint32_t>(ledgerSeq.value_or(0));
2386 
2387  ret.emplace_back(std::move(rawTxn), std::move(txnMeta), seq);
2388  }
2389  }
2390 
2391  return ret;
2392 }
2393 
2396  AccountID const& account,
2397  std::int32_t minLedger,
2398  std::int32_t maxLedger,
2399  bool forward,
2401  int limit,
2402  bool bUnlimited)
2403 {
2404  static std::uint32_t const page_length(200);
2405 
2406  Application& app = app_;
2408 
2409  auto bound = [&ret, &app](
2410  std::uint32_t ledger_index,
2411  std::string const& status,
2412  Blob&& rawTxn,
2413  Blob&& rawMeta) {
2414  convertBlobsToTxResult(ret, ledger_index, status, rawTxn, rawMeta, app);
2415  };
2416 
2417  accountTxPage(
2418  app_.getTxnDB(),
2419  app_.accountIDCache(),
2420  std::bind(saveLedgerAsync, std::ref(app_), std::placeholders::_1),
2421  bound,
2422  account,
2423  minLedger,
2424  maxLedger,
2425  forward,
2426  marker,
2427  limit,
2428  bUnlimited,
2429  page_length);
2430 
2431  return ret;
2432 }
2433 
2436  AccountID const& account,
2437  std::int32_t minLedger,
2438  std::int32_t maxLedger,
2439  bool forward,
2441  int limit,
2442  bool bUnlimited)
2443 {
2444  static const std::uint32_t page_length(500);
2445 
2446  MetaTxsList ret;
2447 
2448  auto bound = [&ret](
2449  std::uint32_t ledgerIndex,
2450  std::string const& status,
2451  Blob&& rawTxn,
2452  Blob&& rawMeta) {
2453  ret.emplace_back(std::move(rawTxn), std::move(rawMeta), ledgerIndex);
2454  };
2455 
2456  accountTxPage(
2457  app_.getTxnDB(),
2458  app_.accountIDCache(),
2459  std::bind(saveLedgerAsync, std::ref(app_), std::placeholders::_1),
2460  bound,
2461  account,
2462  minLedger,
2463  maxLedger,
2464  forward,
2465  marker,
2466  limit,
2467  bUnlimited,
2468  page_length);
2469  return ret;
2470 }
2471 
2472 bool
2474  std::shared_ptr<STValidation> const& val,
2475  std::string const& source)
2476 {
2477  JLOG(m_journal.debug())
2478  << "recvValidation " << val->getLedgerHash() << " from " << source;
2479 
2480  handleNewValidation(app_, val, source);
2481 
2482  pubValidation(val);
2483 
2484  // We will always relay trusted validations; if configured, we will
2485  // also relay all untrusted validations.
2486  return app_.config().RELAY_UNTRUSTED_VALIDATIONS || val->isTrusted();
2487 }
2488 
2491 {
2492  return mConsensus.getJson(true);
2493 }
2494 
2496 NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters)
2497 {
2499 
2500  // System-level warnings
2501  {
2502  Json::Value warnings{Json::arrayValue};
2503  if (isAmendmentBlocked())
2504  {
2505  Json::Value& w = warnings.append(Json::objectValue);
2506  w[jss::id] = warnRPC_AMENDMENT_BLOCKED;
2507  w[jss::message] =
2508  "This server is amendment blocked, and must be updated to be "
2509  "able to stay in sync with the network.";
2510  }
2511  if (admin && isAmendmentWarned())
2512  {
2513  Json::Value& w = warnings.append(Json::objectValue);
2514  w[jss::id] = warnRPC_UNSUPPORTED_MAJORITY;
2515  w[jss::message] =
2516  "One or more unsupported amendments have reached majority. "
2517  "Upgrade to the latest version before they are activated "
2518  "to avoid being amendment blocked.";
2519  if (auto const expected =
2521  {
2522  auto& d = w[jss::details] = Json::objectValue;
2523  d[jss::expected_date] = expected->time_since_epoch().count();
2524  d[jss::expected_date_UTC] = to_string(*expected);
2525  }
2526  }
2527 
2528  if (warnings.size())
2529  info[jss::warnings] = std::move(warnings);
2530  }
2531 
2532  // hostid: unique string describing the machine
2533  if (human)
2534  info[jss::hostid] = getHostId(admin);
2535 
2536  if (auto const netid = app_.overlay().networkID())
2537  info[jss::network_id] = static_cast<Json::UInt>(*netid);
2538 
2539  info[jss::build_version] = BuildInfo::getVersionString();
2540 
2541  info[jss::server_state] = strOperatingMode(admin);
2542 
2543  info[jss::time] = to_string(date::floor<std::chrono::microseconds>(
2545 
2546  if (needNetworkLedger_)
2547  info[jss::network_ledger] = "waiting";
2548 
2549  info[jss::validation_quorum] =
2550  static_cast<Json::UInt>(app_.validators().quorum());
2551 
2552  if (admin)
2553  {
2554  auto when = app_.validators().expires();
2555 
2556  if (!human)
2557  {
2558  if (when)
2559  info[jss::validator_list_expires] =
2560  safe_cast<Json::UInt>(when->time_since_epoch().count());
2561  else
2562  info[jss::validator_list_expires] = 0;
2563  }
2564  else
2565  {
2566  auto& x = (info[jss::validator_list] = Json::objectValue);
2567 
2568  x[jss::count] = static_cast<Json::UInt>(app_.validators().count());
2569 
2570  if (when)
2571  {
2572  if (*when == TimeKeeper::time_point::max())
2573  {
2574  x[jss::expiration] = "never";
2575  x[jss::status] = "active";
2576  }
2577  else
2578  {
2579  x[jss::expiration] = to_string(*when);
2580 
2581  if (*when > app_.timeKeeper().now())
2582  x[jss::status] = "active";
2583  else
2584  x[jss::status] = "expired";
2585  }
2586  }
2587  else
2588  {
2589  x[jss::status] = "unknown";
2590  x[jss::expiration] = "unknown";
2591  }
2592  }
2593  }
2594  info[jss::io_latency_ms] =
2595  static_cast<Json::UInt>(app_.getIOLatency().count());
2596 
2597  if (admin)
2598  {
2600  {
2601  info[jss::pubkey_validator] = toBase58(
2603  }
2604  else
2605  {
2606  info[jss::pubkey_validator] = "none";
2607  }
2608  }
2609 
2610  if (counters)
2611  {
2612  info[jss::counters] = app_.getPerfLog().countersJson();
2613  info[jss::current_activities] = app_.getPerfLog().currentJson();
2614  }
2615 
2616  info[jss::pubkey_node] =
2618 
2619  info[jss::complete_ledgers] = app_.getLedgerMaster().getCompleteLedgers();
2620 
2621  if (amendmentBlocked_)
2622  info[jss::amendment_blocked] = true;
2623 
2624  auto const fp = m_ledgerMaster.getFetchPackCacheSize();
2625 
2626  if (fp != 0)
2627  info[jss::fetch_pack] = Json::UInt(fp);
2628 
2629  info[jss::peers] = Json::UInt(app_.overlay().size());
2630 
2631  Json::Value lastClose = Json::objectValue;
2632  lastClose[jss::proposers] = Json::UInt(mConsensus.prevProposers());
2633 
2634  if (human)
2635  {
2636  lastClose[jss::converge_time_s] =
2638  }
2639  else
2640  {
2641  lastClose[jss::converge_time] =
2643  }
2644 
2645  info[jss::last_close] = lastClose;
2646 
2647  // info[jss::consensus] = mConsensus.getJson();
2648 
2649  if (admin)
2650  info[jss::load] = m_job_queue.getJson();
2651 
2652  auto const escalationMetrics =
2654 
2655  auto const loadFactorServer = app_.getFeeTrack().getLoadFactor();
2656  auto const loadBaseServer = app_.getFeeTrack().getLoadBase();
2657  /* Scale the escalated fee level to unitless "load factor".
2658  In practice, this just strips the units, but it will continue
2659  to work correctly if either base value ever changes. */
2660  auto const loadFactorFeeEscalation =
2661  mulDiv(
2662  escalationMetrics.openLedgerFeeLevel,
2663  loadBaseServer,
2664  escalationMetrics.referenceFeeLevel)
2665  .second;
2666 
2667  auto const loadFactor = std::max(
2668  safe_cast<std::uint64_t>(loadFactorServer), loadFactorFeeEscalation);
2669 
2670  if (!human)
2671  {
2672  info[jss::load_base] = loadBaseServer;
2673  info[jss::load_factor] = trunc32(loadFactor);
2674  info[jss::load_factor_server] = loadFactorServer;
2675 
2676  /* Json::Value doesn't support uint64, so clamp to max
2677  uint32 value. This is mostly theoretical, since there
2678  probably isn't enough extant XRP to drive the factor
2679  that high.
2680  */
2681  info[jss::load_factor_fee_escalation] =
2682  escalationMetrics.openLedgerFeeLevel.jsonClipped();
2683  info[jss::load_factor_fee_queue] =
2684  escalationMetrics.minProcessingFeeLevel.jsonClipped();
2685  info[jss::load_factor_fee_reference] =
2686  escalationMetrics.referenceFeeLevel.jsonClipped();
2687  }
2688  else
2689  {
2690  info[jss::load_factor] =
2691  static_cast<double>(loadFactor) / loadBaseServer;
2692 
2693  if (loadFactorServer != loadFactor)
2694  info[jss::load_factor_server] =
2695  static_cast<double>(loadFactorServer) / loadBaseServer;
2696 
2697  if (admin)
2698  {
2700  if (fee != loadBaseServer)
2701  info[jss::load_factor_local] =
2702  static_cast<double>(fee) / loadBaseServer;
2703  fee = app_.getFeeTrack().getRemoteFee();
2704  if (fee != loadBaseServer)
2705  info[jss::load_factor_net] =
2706  static_cast<double>(fee) / loadBaseServer;
2707  fee = app_.getFeeTrack().getClusterFee();
2708  if (fee != loadBaseServer)
2709  info[jss::load_factor_cluster] =
2710  static_cast<double>(fee) / loadBaseServer;
2711  }
2712  if (escalationMetrics.openLedgerFeeLevel !=
2713  escalationMetrics.referenceFeeLevel &&
2714  (admin || loadFactorFeeEscalation != loadFactor))
2715  info[jss::load_factor_fee_escalation] =
2716  escalationMetrics.openLedgerFeeLevel.decimalFromReference(
2717  escalationMetrics.referenceFeeLevel);
2718  if (escalationMetrics.minProcessingFeeLevel !=
2719  escalationMetrics.referenceFeeLevel)
2720  info[jss::load_factor_fee_queue] =
2721  escalationMetrics.minProcessingFeeLevel.decimalFromReference(
2722  escalationMetrics.referenceFeeLevel);
2723  }
2724 
2725  bool valid = false;
2726  auto lpClosed = m_ledgerMaster.getValidatedLedger();
2727 
2728  if (lpClosed)
2729  valid = true;
2730  else
2731  lpClosed = m_ledgerMaster.getClosedLedger();
2732 
2733  if (lpClosed)
2734  {
2735  XRPAmount const baseFee = lpClosed->fees().base;
2737  l[jss::seq] = Json::UInt(lpClosed->info().seq);
2738  l[jss::hash] = to_string(lpClosed->info().hash);
2739 
2740  if (!human)
2741  {
2742  l[jss::base_fee] = baseFee.jsonClipped();
2743  l[jss::reserve_base] =
2744  lpClosed->fees().accountReserve(0).jsonClipped();
2745  l[jss::reserve_inc] = lpClosed->fees().increment.jsonClipped();
2746  l[jss::close_time] = Json::Value::UInt(
2747  lpClosed->info().closeTime.time_since_epoch().count());
2748  }
2749  else
2750  {
2751  l[jss::base_fee_xrp] = baseFee.decimalXRP();
2752  l[jss::reserve_base_xrp] =
2753  lpClosed->fees().accountReserve(0).decimalXRP();
2754  l[jss::reserve_inc_xrp] = lpClosed->fees().increment.decimalXRP();
2755 
2756  auto const nowOffset = app_.timeKeeper().nowOffset();
2757  if (std::abs(nowOffset.count()) >= 60)
2758  l[jss::system_time_offset] = nowOffset.count();
2759 
2760  auto const closeOffset = app_.timeKeeper().closeOffset();
2761  if (std::abs(closeOffset.count()) >= 60)
2762  l[jss::close_time_offset] = closeOffset.count();
2763 
2764  constexpr std::chrono::seconds highAgeThreshold{1000000};
2766  {
2767  auto const age = m_ledgerMaster.getValidatedLedgerAge();
2768  l[jss::age] =
2769  Json::UInt(age < highAgeThreshold ? age.count() : 0);
2770  }
2771  else
2772  {
2773  auto lCloseTime = lpClosed->info().closeTime;
2774  auto closeTime = app_.timeKeeper().closeTime();
2775  if (lCloseTime <= closeTime)
2776  {
2777  using namespace std::chrono_literals;
2778  auto age = closeTime - lCloseTime;
2779  l[jss::age] =
2780  Json::UInt(age < highAgeThreshold ? age.count() : 0);
2781  }
2782  }
2783  }
2784 
2785  if (valid)
2786  info[jss::validated_ledger] = l;
2787  else
2788  info[jss::closed_ledger] = l;
2789 
2790  auto lpPublished = m_ledgerMaster.getPublishedLedger();
2791  if (!lpPublished)
2792  info[jss::published_ledger] = "none";
2793  else if (lpPublished->info().seq != lpClosed->info().seq)
2794  info[jss::published_ledger] = lpPublished->info().seq;
2795  }
2796 
2797  std::tie(info[jss::state_accounting], info[jss::server_state_duration_us]) =
2798  accounting_.json();
2799  info[jss::uptime] = UptimeClock::now().time_since_epoch().count();
2800  info[jss::jq_trans_overflow] =
2802  info[jss::peer_disconnects] =
2804  info[jss::peer_disconnects_resources] =
2806 
2807  return info;
2808 }
2809 
2810 void
2812 {
2814 }
2815 
2818 {
2819  return app_.getInboundLedgers().getInfo();
2820 }
2821 
2822 void
2824  std::shared_ptr<ReadView const> const& lpCurrent,
2825  std::shared_ptr<STTx const> const& stTxn,
2826  TER terResult)
2827 {
2828  Json::Value jvObj = transJson(*stTxn, terResult, false, lpCurrent);
2829 
2830  {
2832 
2833  auto it = mStreamMaps[sRTTransactions].begin();
2834  while (it != mStreamMaps[sRTTransactions].end())
2835  {
2836  InfoSub::pointer p = it->second.lock();
2837 
2838  if (p)
2839  {
2840  p->send(jvObj, true);
2841  ++it;
2842  }
2843  else
2844  {
2845  it = mStreamMaps[sRTTransactions].erase(it);
2846  }
2847  }
2848  }
2849  AcceptedLedgerTx alt(
2850  lpCurrent, stTxn, terResult, app_.accountIDCache(), app_.logs());
2851  JLOG(m_journal.trace()) << "pubProposed: " << alt.getJson();
2852  pubAccountTransaction(lpCurrent, alt, false);
2853 }
2854 
2855 void
2857 {
2858  // Ledgers are published only when they acquire sufficient validations
2859  // Holes are filled across connection loss or other catastrophe
2860 
2861  std::shared_ptr<AcceptedLedger> alpAccepted =
2862  app_.getAcceptedLedgerCache().fetch(lpAccepted->info().hash);
2863  if (!alpAccepted)
2864  {
2865  alpAccepted = std::make_shared<AcceptedLedger>(
2866  lpAccepted, app_.accountIDCache(), app_.logs());
2867  app_.getAcceptedLedgerCache().canonicalize_replace_client(
2868  lpAccepted->info().hash, alpAccepted);
2869  }
2870 
2871  {
2873 
2874  if (!mStreamMaps[sLedger].empty())
2875  {
2877 
2878  jvObj[jss::type] = "ledgerClosed";
2879  jvObj[jss::ledger_index] = lpAccepted->info().seq;
2880  jvObj[jss::ledger_hash] = to_string(lpAccepted->info().hash);
2881  jvObj[jss::ledger_time] = Json::Value::UInt(
2882  lpAccepted->info().closeTime.time_since_epoch().count());
2883 
2884  jvObj[jss::fee_ref] = lpAccepted->fees().units.jsonClipped();
2885  jvObj[jss::fee_base] = lpAccepted->fees().base.jsonClipped();
2886  jvObj[jss::reserve_base] =
2887  lpAccepted->fees().accountReserve(0).jsonClipped();
2888  jvObj[jss::reserve_inc] =
2889  lpAccepted->fees().increment.jsonClipped();
2890 
2891  jvObj[jss::txn_count] = Json::UInt(alpAccepted->getTxnCount());
2892 
2894  {
2895  jvObj[jss::validated_ledgers] =
2897  }
2898 
2899  auto it = mStreamMaps[sLedger].begin();
2900  while (it != mStreamMaps[sLedger].end())
2901  {
2902  InfoSub::pointer p = it->second.lock();
2903  if (p)
2904  {
2905  p->send(jvObj, true);
2906  ++it;
2907  }
2908  else
2909  it = mStreamMaps[sLedger].erase(it);
2910  }
2911  }
2912  }
2913 
2914  // Don't lock since pubAcceptedTransaction is locking.
2915  for (auto const& [_, accTx] : alpAccepted->getMap())
2916  {
2917  (void)_;
2918  JLOG(m_journal.trace()) << "pubAccepted: " << accTx->getJson();
2919  pubValidatedTransaction(lpAccepted, *accTx);
2920  }
2921 }
2922 
2923 void
2925 {
2926  ServerFeeSummary f{
2927  app_.openLedger().current()->fees().base,
2929  app_.getFeeTrack()};
2930 
2931  // only schedule the job if something has changed
2932  if (f != mLastFeeSummary)
2933  {
2935  jtCLIENT, "reportFeeChange->pubServer", [this](Job&) {
2936  pubServer();
2937  });
2938  }
2939 }
2940 
2941 void
2943 {
2945  jtCLIENT,
2946  "reportConsensusStateChange->pubConsensus",
2947  [this, phase](Job&) { pubConsensus(phase); });
2948 }
2949 
2950 // This routine should only be used to publish accepted or validated
2951 // transactions.
2954  const STTx& stTxn,
2955  TER terResult,
2956  bool bValidated,
2957  std::shared_ptr<ReadView const> const& lpCurrent)
2958 {
2960  std::string sToken;
2961  std::string sHuman;
2962 
2963  transResultInfo(terResult, sToken, sHuman);
2964 
2965  jvObj[jss::type] = "transaction";
2966  jvObj[jss::transaction] = stTxn.getJson(JsonOptions::none);
2967 
2968  if (bValidated)
2969  {
2970  jvObj[jss::ledger_index] = lpCurrent->info().seq;
2971  jvObj[jss::ledger_hash] = to_string(lpCurrent->info().hash);
2972  jvObj[jss::transaction][jss::date] =
2973  lpCurrent->info().closeTime.time_since_epoch().count();
2974  jvObj[jss::validated] = true;
2975 
2976  // WRITEME: Put the account next seq here
2977  }
2978  else
2979  {
2980  jvObj[jss::validated] = false;
2981  jvObj[jss::ledger_current_index] = lpCurrent->info().seq;
2982  }
2983 
2984  jvObj[jss::status] = bValidated ? "closed" : "proposed";
2985  jvObj[jss::engine_result] = sToken;
2986  jvObj[jss::engine_result_code] = terResult;
2987  jvObj[jss::engine_result_message] = sHuman;
2988 
2989  if (stTxn.getTxnType() == ttOFFER_CREATE)
2990  {
2991  auto const account = stTxn.getAccountID(sfAccount);
2992  auto const amount = stTxn.getFieldAmount(sfTakerGets);
2993 
2994  // If the offer create is not self funded then add the owner balance
2995  if (account != amount.issue().account)
2996  {
2997  auto const ownerFunds = accountFunds(
2998  *lpCurrent,
2999  account,
3000  amount,
3002  app_.journal("View"));
3003  jvObj[jss::transaction][jss::owner_funds] = ownerFunds.getText();
3004  }
3005  }
3006 
3007  return jvObj;
3008 }
3009 
3010 void
3012  std::shared_ptr<ReadView const> const& alAccepted,
3013  const AcceptedLedgerTx& alTx)
3014 {
3015  std::shared_ptr<STTx const> stTxn = alTx.getTxn();
3016  Json::Value jvObj = transJson(*stTxn, alTx.getResult(), true, alAccepted);
3017 
3018  if (auto const txMeta = alTx.getMeta())
3019  {
3020  jvObj[jss::meta] = txMeta->getJson(JsonOptions::none);
3022  jvObj[jss::meta], *alAccepted, stTxn, *txMeta);
3023  }
3024 
3025  {
3027 
3028  auto it = mStreamMaps[sTransactions].begin();
3029  while (it != mStreamMaps[sTransactions].end())
3030  {
3031  InfoSub::pointer p = it->second.lock();
3032 
3033  if (p)
3034  {
3035  p->send(jvObj, true);
3036  ++it;
3037  }
3038  else
3039  it = mStreamMaps[sTransactions].erase(it);
3040  }
3041 
3042  it = mStreamMaps[sRTTransactions].begin();
3043 
3044  while (it != mStreamMaps[sRTTransactions].end())
3045  {
3046  InfoSub::pointer p = it->second.lock();
3047 
3048  if (p)
3049  {
3050  p->send(jvObj, true);
3051  ++it;
3052  }
3053  else
3054  it = mStreamMaps[sRTTransactions].erase(it);
3055  }
3056  }
3057  app_.getOrderBookDB().processTxn(alAccepted, alTx, jvObj);
3058  pubAccountTransaction(alAccepted, alTx, true);
3059 }
3060 
3061 void
3063  std::shared_ptr<ReadView const> const& lpCurrent,
3064  const AcceptedLedgerTx& alTx,
3065  bool bAccepted)
3066 {
3068  int iProposed = 0;
3069  int iAccepted = 0;
3070 
3071  {
3073 
3074  if (!bAccepted && mSubRTAccount.empty())
3075  return;
3076 
3077  if (!mSubAccount.empty() || (!mSubRTAccount.empty()))
3078  {
3079  for (auto const& affectedAccount : alTx.getAffected())
3080  {
3081  auto simiIt = mSubRTAccount.find(affectedAccount);
3082  if (simiIt != mSubRTAccount.end())
3083  {
3084  auto it = simiIt->second.begin();
3085 
3086  while (it != simiIt->second.end())
3087  {
3088  InfoSub::pointer p = it->second.lock();
3089 
3090  if (p)
3091  {
3092  notify.insert(p);
3093  ++it;
3094  ++iProposed;
3095  }
3096  else
3097  it = simiIt->second.erase(it);
3098  }
3099  }
3100 
3101  if (bAccepted)
3102  {
3103  simiIt = mSubAccount.find(affectedAccount);
3104 
3105  if (simiIt != mSubAccount.end())
3106  {
3107  auto it = simiIt->second.begin();
3108  while (it != simiIt->second.end())
3109  {
3110  InfoSub::pointer p = it->second.lock();
3111 
3112  if (p)
3113  {
3114  notify.insert(p);
3115  ++it;
3116  ++iAccepted;
3117  }
3118  else
3119  it = simiIt->second.erase(it);
3120  }
3121  }
3122  }
3123  }
3124  }
3125  }
3126  JLOG(m_journal.trace())
3127  << "pubAccountTransaction:"
3128  << " iProposed=" << iProposed << " iAccepted=" << iAccepted;
3129 
3130  if (!notify.empty())
3131  {
3132  std::shared_ptr<STTx const> stTxn = alTx.getTxn();
3133  Json::Value jvObj =
3134  transJson(*stTxn, alTx.getResult(), bAccepted, lpCurrent);
3135 
3136  if (alTx.isApplied())
3137  {
3138  if (auto const txMeta = alTx.getMeta())
3139  {
3140  jvObj[jss::meta] = txMeta->getJson(JsonOptions::none);
3142  jvObj[jss::meta], *lpCurrent, stTxn, *txMeta);
3143  }
3144  }
3145 
3146  for (InfoSub::ref isrListener : notify)
3147  isrListener->send(jvObj, true);
3148  }
3149 }
3150 
3151 //
3152 // Monitoring
3153 //
3154 
3155 void
3157  InfoSub::ref isrListener,
3158  hash_set<AccountID> const& vnaAccountIDs,
3159  bool rt)
3160 {
3161  SubInfoMapType& subMap = rt ? mSubRTAccount : mSubAccount;
3162 
3163  for (auto const& naAccountID : vnaAccountIDs)
3164  {
3165  JLOG(m_journal.trace())
3166  << "subAccount: account: " << toBase58(naAccountID);
3167 
3168  isrListener->insertSubAccountInfo(naAccountID, rt);
3169  }
3170 
3172 
3173  for (auto const& naAccountID : vnaAccountIDs)
3174  {
3175  auto simIterator = subMap.find(naAccountID);
3176  if (simIterator == subMap.end())
3177  {
3178  // Not found, note that account has a new single listner.
3179  SubMapType usisElement;
3180  usisElement[isrListener->getSeq()] = isrListener;
3181  // VFALCO NOTE This is making a needless copy of naAccountID
3182  subMap.insert(simIterator, make_pair(naAccountID, usisElement));
3183  }
3184  else
3185  {
3186  // Found, note that the account has another listener.
3187  simIterator->second[isrListener->getSeq()] = isrListener;
3188  }
3189  }
3190 }
3191 
3192 void
3194  InfoSub::ref isrListener,
3195  hash_set<AccountID> const& vnaAccountIDs,
3196  bool rt)
3197 {
3198  for (auto const& naAccountID : vnaAccountIDs)
3199  {
3200  // Remove from the InfoSub
3201  isrListener->deleteSubAccountInfo(naAccountID, rt);
3202  }
3203 
3204  // Remove from the server
3205  unsubAccountInternal(isrListener->getSeq(), vnaAccountIDs, rt);
3206 }
3207 
3208 void
3210  std::uint64_t uSeq,
3211  hash_set<AccountID> const& vnaAccountIDs,
3212  bool rt)
3213 {
3215 
3216  SubInfoMapType& subMap = rt ? mSubRTAccount : mSubAccount;
3217 
3218  for (auto const& naAccountID : vnaAccountIDs)
3219  {
3220  auto simIterator = subMap.find(naAccountID);
3221 
3222  if (simIterator != subMap.end())
3223  {
3224  // Found
3225  simIterator->second.erase(uSeq);
3226 
3227  if (simIterator->second.empty())
3228  {
3229  // Don't need hash entry.
3230  subMap.erase(simIterator);
3231  }
3232  }
3233  }
3234 }
3235 
3236 bool
3237 NetworkOPsImp::subBook(InfoSub::ref isrListener, Book const& book)
3238 {
3239  if (auto listeners = app_.getOrderBookDB().makeBookListeners(book))
3240  listeners->addSubscriber(isrListener);
3241  else
3242  assert(false);
3243  return true;
3244 }
3245 
3246 bool
3248 {
3249  if (auto listeners = app_.getOrderBookDB().getBookListeners(book))
3250  listeners->removeSubscriber(uSeq);
3251 
3252  return true;
3253 }
3254 
3257  boost::optional<std::chrono::milliseconds> consensusDelay)
3258 {
3259  // This code-path is exclusively used when the server is in standalone
3260  // mode via `ledger_accept`
3261  assert(m_standalone);
3262 
3263  if (!m_standalone)
3264  Throw<std::runtime_error>(
3265  "Operation only possible in STANDALONE mode.");
3266 
3267  // FIXME Could we improve on this and remove the need for a specialized
3268  // API in Consensus?
3270  mConsensus.simulate(app_.timeKeeper().closeTime(), consensusDelay);
3271  return m_ledgerMaster.getCurrentLedger()->info().seq;
3272 }
3273 
3274 // <-- bool: true=added, false=already there
3275 bool
3277 {
3278  if (auto lpClosed = m_ledgerMaster.getValidatedLedger())
3279  {
3280  jvResult[jss::ledger_index] = lpClosed->info().seq;
3281  jvResult[jss::ledger_hash] = to_string(lpClosed->info().hash);
3282  jvResult[jss::ledger_time] = Json::Value::UInt(
3283  lpClosed->info().closeTime.time_since_epoch().count());
3284  jvResult[jss::fee_ref] = lpClosed->fees().units.jsonClipped();
3285  jvResult[jss::fee_base] = lpClosed->fees().base.jsonClipped();
3286  jvResult[jss::reserve_base] =
3287  lpClosed->fees().accountReserve(0).jsonClipped();
3288  jvResult[jss::reserve_inc] = lpClosed->fees().increment.jsonClipped();
3289  }
3290 
3292  {
3293  jvResult[jss::validated_ledgers] =
3295  }
3296 
3298  return mStreamMaps[sLedger]
3299  .emplace(isrListener->getSeq(), isrListener)
3300  .second;
3301 }
3302 
3303 // <-- bool: true=erased, false=was not there
3304 bool
3306 {
3308  return mStreamMaps[sLedger].erase(uSeq);
3309 }
3310 
3311 // <-- bool: true=added, false=already there
3312 bool
3314 {
3316  return mStreamMaps[sManifests]
3317  .emplace(isrListener->getSeq(), isrListener)
3318  .second;
3319 }
3320 
3321 // <-- bool: true=erased, false=was not there
3322 bool
3324 {
3326  return mStreamMaps[sManifests].erase(uSeq);
3327 }
3328 
3329 // <-- bool: true=added, false=already there
3330 bool
3332  InfoSub::ref isrListener,
3333  Json::Value& jvResult,
3334  bool admin)
3335 {
3336  uint256 uRandom;
3337 
3338  if (m_standalone)
3339  jvResult[jss::stand_alone] = m_standalone;
3340 
3341  // CHECKME: is it necessary to provide a random number here?
3342  beast::rngfill(uRandom.begin(), uRandom.size(), crypto_prng());
3343 
3344  auto const& feeTrack = app_.getFeeTrack();
3345  jvResult[jss::random] = to_string(uRandom);
3346  jvResult[jss::server_status] = strOperatingMode(admin);
3347  jvResult[jss::load_base] = feeTrack.getLoadBase();
3348  jvResult[jss::load_factor] = feeTrack.getLoadFactor();
3349  jvResult[jss::hostid] = getHostId(admin);
3350  jvResult[jss::pubkey_node] =
3352 
3354  return mStreamMaps[sServer]
3355  .emplace(isrListener->getSeq(), isrListener)
3356  .second;
3357 }
3358 
3359 // <-- bool: true=erased, false=was not there
3360 bool
3362 {
3364  return mStreamMaps[sServer].erase(uSeq);
3365 }
3366 
3367 // <-- bool: true=added, false=already there
3368 bool
3370 {
3372  return mStreamMaps[sTransactions]
3373  .emplace(isrListener->getSeq(), isrListener)
3374  .second;
3375 }
3376 
3377 // <-- bool: true=erased, false=was not there
3378 bool
3380 {
3382  return mStreamMaps[sTransactions].erase(uSeq);
3383 }
3384 
3385 // <-- bool: true=added, false=already there
3386 bool
3388 {
3391  .emplace(isrListener->getSeq(), isrListener)
3392  .second;
3393 }
3394 
3395 // <-- bool: true=erased, false=was not there
3396 bool
3398 {
3400  return mStreamMaps[sRTTransactions].erase(uSeq);
3401 }
3402 
3403 // <-- bool: true=added, false=already there
3404 bool
3406 {
3408  return mStreamMaps[sValidations]
3409  .emplace(isrListener->getSeq(), isrListener)
3410  .second;
3411 }
3412 
3413 // <-- bool: true=erased, false=was not there
3414 bool
3416 {
3418  return mStreamMaps[sValidations].erase(uSeq);
3419 }
3420 
3421 // <-- bool: true=added, false=already there
3422 bool
3424 {
3426  return mStreamMaps[sPeerStatus]
3427  .emplace(isrListener->getSeq(), isrListener)
3428  .second;
3429 }
3430 
3431 // <-- bool: true=erased, false=was not there
3432 bool
3434 {
3436  return mStreamMaps[sPeerStatus].erase(uSeq);
3437 }
3438 
3439 // <-- bool: true=added, false=already there
3440 bool
3442 {
3445  .emplace(isrListener->getSeq(), isrListener)
3446  .second;
3447 }
3448 
3449 // <-- bool: true=erased, false=was not there
3450 bool
3452 {
3454  return mStreamMaps[sConsensusPhase].erase(uSeq);
3455 }
3456 
3459 {
3461 
3462  subRpcMapType::iterator it = mRpcSubMap.find(strUrl);
3463 
3464  if (it != mRpcSubMap.end())
3465  return it->second;
3466 
3467  return InfoSub::pointer();
3468 }
3469 
3472 {
3474 
3475  mRpcSubMap.emplace(strUrl, rspEntry);
3476 
3477  return rspEntry;
3478 }
3479 
3480 bool
3482 {
3484  auto pInfo = findRpcSub(strUrl);
3485 
3486  if (!pInfo)
3487  return false;
3488 
3489  // check to see if any of the stream maps still hold a weak reference to
3490  // this entry before removing
3491  for (SubMapType const& map : mStreamMaps)
3492  {
3493  if (map.find(pInfo->getSeq()) != map.end())
3494  return false;
3495  }
3496  mRpcSubMap.erase(strUrl);
3497  return true;
3498 }
3499 
3500 #ifndef USE_NEW_BOOK_PAGE
3501 
3502 // NIKB FIXME this should be looked at. There's no reason why this shouldn't
3503 // work, but it demonstrated poor performance.
3504 //
3505 void
3508  Book const& book,
3509  AccountID const& uTakerID,
3510  bool const bProof,
3511  unsigned int iLimit,
3512  Json::Value const& jvMarker,
3513  Json::Value& jvResult)
3514 { // CAUTION: This is the old get book page logic
3515  Json::Value& jvOffers =
3516  (jvResult[jss::offers] = Json::Value(Json::arrayValue));
3517 
3519  const uint256 uBookBase = getBookBase(book);
3520  const uint256 uBookEnd = getQualityNext(uBookBase);
3521  uint256 uTipIndex = uBookBase;
3522 
3523  if (auto stream = m_journal.trace())
3524  {
3525  stream << "getBookPage:" << book;
3526  stream << "getBookPage: uBookBase=" << uBookBase;
3527  stream << "getBookPage: uBookEnd=" << uBookEnd;
3528  stream << "getBookPage: uTipIndex=" << uTipIndex;
3529  }
3530 
3531  ReadView const& view = *lpLedger;
3532 
3533  bool const bGlobalFreeze = isGlobalFrozen(view, book.out.account) ||
3534  isGlobalFrozen(view, book.in.account);
3535 
3536  bool bDone = false;
3537  bool bDirectAdvance = true;
3538 
3539  std::shared_ptr<SLE const> sleOfferDir;
3540  uint256 offerIndex;
3541  unsigned int uBookEntry;
3542  STAmount saDirRate;
3543 
3544  auto const rate = transferRate(view, book.out.account);
3545  auto viewJ = app_.journal("View");
3546 
3547  while (!bDone && iLimit-- > 0)
3548  {
3549  if (bDirectAdvance)
3550  {
3551  bDirectAdvance = false;
3552 
3553  JLOG(m_journal.trace()) << "getBookPage: bDirectAdvance";
3554 
3555  auto const ledgerIndex = view.succ(uTipIndex, uBookEnd);
3556  if (ledgerIndex)
3557  sleOfferDir = view.read(keylet::page(*ledgerIndex));
3558  else
3559  sleOfferDir.reset();
3560 
3561  if (!sleOfferDir)
3562  {
3563  JLOG(m_journal.trace()) << "getBookPage: bDone";
3564  bDone = true;
3565  }
3566  else
3567  {
3568  uTipIndex = sleOfferDir->key();
3569  saDirRate = amountFromQuality(getQuality(uTipIndex));
3570 
3571  cdirFirst(
3572  view,
3573  uTipIndex,
3574  sleOfferDir,
3575  uBookEntry,
3576  offerIndex,
3577  viewJ);
3578 
3579  JLOG(m_journal.trace())
3580  << "getBookPage: uTipIndex=" << uTipIndex;
3581  JLOG(m_journal.trace())
3582  << "getBookPage: offerIndex=" << offerIndex;
3583  }
3584  }
3585 
3586  if (!bDone)
3587  {
3588  auto sleOffer = view.read(keylet::offer(offerIndex));
3589 
3590  if (sleOffer)
3591  {
3592  auto const uOfferOwnerID = sleOffer->getAccountID(sfAccount);
3593  auto const& saTakerGets = sleOffer->getFieldAmount(sfTakerGets);
3594  auto const& saTakerPays = sleOffer->getFieldAmount(sfTakerPays);
3595  STAmount saOwnerFunds;
3596  bool firstOwnerOffer(true);
3597 
3598  if (book.out.account == uOfferOwnerID)
3599  {
3600  // If an offer is selling issuer's own IOUs, it is fully
3601  // funded.
3602  saOwnerFunds = saTakerGets;
3603  }
3604  else if (bGlobalFreeze)
3605  {
3606  // If either asset is globally frozen, consider all offers
3607  // that aren't ours to be totally unfunded
3608  saOwnerFunds.clear(book.out);
3609  }
3610  else
3611  {
3612  auto umBalanceEntry = umBalance.find(uOfferOwnerID);
3613  if (umBalanceEntry != umBalance.end())
3614  {
3615  // Found in running balance table.
3616 
3617  saOwnerFunds = umBalanceEntry->second;
3618  firstOwnerOffer = false;
3619  }
3620  else
3621  {
3622  // Did not find balance in table.
3623 
3624  saOwnerFunds = accountHolds(
3625  view,
3626  uOfferOwnerID,
3627  book.out.currency,
3628  book.out.account,
3630  viewJ);
3631 
3632  if (saOwnerFunds < beast::zero)
3633  {
3634  // Treat negative funds as zero.
3635 
3636  saOwnerFunds.clear();
3637  }
3638  }
3639  }
3640 
3641  Json::Value jvOffer = sleOffer->getJson(JsonOptions::none);
3642 
3643  STAmount saTakerGetsFunded;
3644  STAmount saOwnerFundsLimit = saOwnerFunds;
3645  Rate offerRate = parityRate;
3646 
3647  if (rate != parityRate
3648  // Have a tranfer fee.
3649  && uTakerID != book.out.account
3650  // Not taking offers of own IOUs.
3651  && book.out.account != uOfferOwnerID)
3652  // Offer owner not issuing ownfunds
3653  {
3654  // Need to charge a transfer fee to offer owner.
3655  offerRate = rate;
3656  saOwnerFundsLimit = divide(saOwnerFunds, offerRate);
3657  }
3658 
3659  if (saOwnerFundsLimit >= saTakerGets)
3660  {
3661  // Sufficient funds no shenanigans.
3662  saTakerGetsFunded = saTakerGets;
3663  }
3664  else
3665  {
3666  // Only provide, if not fully funded.
3667 
3668  saTakerGetsFunded = saOwnerFundsLimit;
3669 
3670  saTakerGetsFunded.setJson(jvOffer[jss::taker_gets_funded]);
3671  std::min(
3672  saTakerPays,
3673  multiply(
3674  saTakerGetsFunded, saDirRate, saTakerPays.issue()))
3675  .setJson(jvOffer[jss::taker_pays_funded]);
3676  }
3677 
3678  STAmount saOwnerPays = (parityRate == offerRate)
3679  ? saTakerGetsFunded
3680  : std::min(
3681  saOwnerFunds, multiply(saTakerGetsFunded, offerRate));
3682 
3683  umBalance[uOfferOwnerID] = saOwnerFunds - saOwnerPays;
3684 
3685  // Include all offers funded and unfunded
3686  Json::Value& jvOf = jvOffers.append(jvOffer);
3687  jvOf[jss::quality] = saDirRate.getText();
3688 
3689  if (firstOwnerOffer)
3690  jvOf[jss::owner_funds] = saOwnerFunds.getText();
3691  }
3692  else
3693  {
3694  JLOG(m_journal.warn()) << "Missing offer";
3695  }
3696 
3697  if (!cdirNext(
3698  view,
3699  uTipIndex,
3700  sleOfferDir,
3701  uBookEntry,
3702  offerIndex,
3703  viewJ))
3704  {
3705  bDirectAdvance = true;
3706  }
3707  else
3708  {
3709  JLOG(m_journal.trace())
3710  << "getBookPage: offerIndex=" << offerIndex;
3711  }
3712  }
3713  }
3714 
3715  // jvResult[jss::marker] = Json::Value(Json::arrayValue);
3716  // jvResult[jss::nodes] = Json::Value(Json::arrayValue);
3717 }
3718 
3719 #else
3720 
3721 // This is the new code that uses the book iterators
3722 // It has temporarily been disabled
3723 
3724 void
3727  Book const& book,
3728  AccountID const& uTakerID,
3729  bool const bProof,
3730  unsigned int iLimit,
3731  Json::Value const& jvMarker,
3732  Json::Value& jvResult)
3733 {
3734  auto& jvOffers = (jvResult[jss::offers] = Json::Value(Json::arrayValue));
3735 
3737 
3738  MetaView lesActive(lpLedger, tapNONE, true);
3739  OrderBookIterator obIterator(lesActive, book);
3740 
3741  auto const rate = transferRate(lesActive, book.out.account);
3742 
3743  const bool bGlobalFreeze = lesActive.isGlobalFrozen(book.out.account) ||
3744  lesActive.isGlobalFrozen(book.in.account);
3745 
3746  while (iLimit-- > 0 && obIterator.nextOffer())
3747  {
3748  SLE::pointer sleOffer = obIterator.getCurrentOffer();
3749  if (sleOffer)
3750  {
3751  auto const uOfferOwnerID = sleOffer->getAccountID(sfAccount);
3752  auto const& saTakerGets = sleOffer->getFieldAmount(sfTakerGets);
3753  auto const& saTakerPays = sleOffer->getFieldAmount(sfTakerPays);
3754  STAmount saDirRate = obIterator.getCurrentRate();
3755  STAmount saOwnerFunds;
3756 
3757  if (book.out.account == uOfferOwnerID)
3758  {
3759  // If offer is selling issuer's own IOUs, it is fully funded.
3760  saOwnerFunds = saTakerGets;
3761  }
3762  else if (bGlobalFreeze)
3763  {
3764  // If either asset is globally frozen, consider all offers
3765  // that aren't ours to be totally unfunded
3766  saOwnerFunds.clear(book.out);
3767  }
3768  else
3769  {
3770  auto umBalanceEntry = umBalance.find(uOfferOwnerID);
3771 
3772  if (umBalanceEntry != umBalance.end())
3773  {
3774  // Found in running balance table.
3775 
3776  saOwnerFunds = umBalanceEntry->second;
3777  }
3778  else
3779  {
3780  // Did not find balance in table.
3781 
3782  saOwnerFunds = lesActive.accountHolds(
3783  uOfferOwnerID,
3784  book.out.currency,
3785  book.out.account,
3787 
3788  if (saOwnerFunds.isNegative())
3789  {
3790  // Treat negative funds as zero.
3791 
3792  saOwnerFunds.zero();
3793  }
3794  }
3795  }
3796 
3797  Json::Value jvOffer = sleOffer->getJson(JsonOptions::none);
3798 
3799  STAmount saTakerGetsFunded;
3800  STAmount saOwnerFundsLimit = saOwnerFunds;
3801  Rate offerRate = parityRate;
3802 
3803  if (rate != parityRate
3804  // Have a tranfer fee.
3805  && uTakerID != book.out.account
3806  // Not taking offers of own IOUs.
3807  && book.out.account != uOfferOwnerID)
3808  // Offer owner not issuing ownfunds
3809  {
3810  // Need to charge a transfer fee to offer owner.
3811  offerRate = rate;
3812  saOwnerFundsLimit = divide(saOwnerFunds, offerRate);
3813  }
3814 
3815  if (saOwnerFundsLimit >= saTakerGets)
3816  {
3817  // Sufficient funds no shenanigans.
3818  saTakerGetsFunded = saTakerGets;
3819  }
3820  else
3821  {
3822  // Only provide, if not fully funded.
3823  saTakerGetsFunded = saOwnerFundsLimit;
3824 
3825  saTakerGetsFunded.setJson(jvOffer[jss::taker_gets_funded]);
3826 
3827  // TOOD(tom): The result of this expression is not used - what's
3828  // going on here?
3829  std::min(
3830  saTakerPays,
3831  multiply(saTakerGetsFunded, saDirRate, saTakerPays.issue()))
3832  .setJson(jvOffer[jss::taker_pays_funded]);
3833  }
3834 
3835  STAmount saOwnerPays = (parityRate == offerRate)
3836  ? saTakerGetsFunded
3837  : std::min(
3838  saOwnerFunds, multiply(saTakerGetsFunded, offerRate));
3839 
3840  umBalance[uOfferOwnerID] = saOwnerFunds - saOwnerPays;
3841 
3842  if (!saOwnerFunds.isZero() || uOfferOwnerID == uTakerID)
3843  {
3844  // Only provide funded offers and offers of the taker.
3845  Json::Value& jvOf = jvOffers.append(jvOffer);
3846  jvOf[jss::quality] = saDirRate.getText();
3847  }
3848  }
3849  }
3850 
3851  // jvResult[jss::marker] = Json::Value(Json::arrayValue);
3852  // jvResult[jss::nodes] = Json::Value(Json::arrayValue);
3853 }
3854 
3855 #endif
3856 
3857 //------------------------------------------------------------------------------
3858 
3860  : InfoSub::Source("NetworkOPs", parent)
3861 {
3862 }
3863 
3864 //------------------------------------------------------------------------------
3865 
3866 void
3868 {
3869  auto now = std::chrono::system_clock::now();
3870 
3871  std::lock_guard lock(mutex_);
3872  ++counters_[static_cast<std::size_t>(om)].transitions;
3873  counters_[static_cast<std::size_t>(mode_)].dur +=
3874  std::chrono::duration_cast<std::chrono::microseconds>(now - start_);
3875 
3876  mode_ = om;
3877  start_ = now;
3878 }
3879 
3882 {
3883  auto [counters, mode, start] = getCounterData();
3884  auto const current = std::chrono::duration_cast<std::chrono::microseconds>(
3885  std::chrono::system_clock::now() - start);
3886  counters[static_cast<std::size_t>(mode)].dur += current;
3887 
3889 
3890  for (std::size_t i = static_cast<std::size_t>(OperatingMode::DISCONNECTED);
3891  i <= static_cast<std::size_t>(OperatingMode::FULL);
3892  ++i)
3893  {
3894  ret[states_[i]] = Json::objectValue;
3895  auto& state = ret[states_[i]];
3896  state[jss::transitions] = counters[i].transitions;
3897  state[jss::duration_us] = std::to_string(counters[i].dur.count());
3898  }
3899 
3900  return {ret, std::to_string(current.count())};
3901 }
3902 
3903 //------------------------------------------------------------------------------
3904 
3907  Application& app,
3908  NetworkOPs::clock_type& clock,
3909  bool standalone,
3910  std::size_t minPeerCount,
3911  bool startvalid,
3912  JobQueue& job_queue,
3913  LedgerMaster& ledgerMaster,
3914  Stoppable& parent,
3915  ValidatorKeys const& validatorKeys,
3916  boost::asio::io_service& io_svc,
3917  beast::Journal journal,
3918  beast::insight::Collector::ptr const& collector)
3919 {
3920  return std::make_unique<NetworkOPsImp>(
3921  app,
3922  clock,
3923  standalone,
3924  minPeerCount,
3925  startvalid,
3926  job_queue,
3927  ledgerMaster,
3928  parent,
3929  validatorKeys,
3930  io_svc,
3931  journal,
3932  collector);
3933 }
3934 
3935 } // namespace ripple
ripple::NetworkOPsImp::unsubValidations
bool unsubValidations(std::uint64_t uListener) override
Definition: NetworkOPs.cpp:3415
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:3405
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:285
ripple::NetworkOPsImp::mapComplete
void mapComplete(std::shared_ptr< SHAMap > const &map, bool fromAcquire) override
Definition: NetworkOPs.cpp:1792
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:3451
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:1780
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:1786
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:2173
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:395
ripple::NetworkOPsImp::m_journal
beast::Journal m_journal
Definition: NetworkOPs.cpp:712
ripple::LedgerMaster::getPublishedLedger
std::shared_ptr< ReadView const > getPublishedLedger()
Definition: LedgerMaster.cpp:1551
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:2823
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:301
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:88
ripple::make_FeeVote
std::unique_ptr< FeeVote > make_FeeVote(FeeVote::Setup const &setup, beast::Journal journal)
Create an instance of the FeeVote logic.
Definition: FeeVoteImpl.cpp:279
ripple::LedgerMaster::pruneHeldTransactions
std::vector< std::shared_ptr< STTx const > > pruneHeldTransactions(AccountID const &account, std::uint32_t const seq)
Get all the transactions held for a particular account.
Definition: LedgerMaster.cpp:547
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:2435
ripple::isTesSuccess
bool isTesSuccess(TER x)
Definition: TER.h:576
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:1876
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:3423
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:597
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:2144
ripple::ClusterNode::name
std::string const & name() const
Definition: ClusterNode.h:45
ripple::OpenView
Writable ledger view that accumulates state and tx changes.
Definition: OpenView.h:52
ripple::cdirNext
bool cdirNext(ReadView const &view, uint256 const &uRootIndex, std::shared_ptr< SLE const > &sleNode, unsigned int &uDirEntry, uint256 &uEntryIndex, beast::Journal j)
Definition: View.cpp:495
ripple::NetworkOPsImp::strOperatingMode
std::string strOperatingMode(bool const admin=false) const override
Definition: NetworkOPs.cpp: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:78
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:3256
ripple::NetworkOPsImp::setNeedNetworkLedger
void setNeedNetworkLedger() override
Definition: NetworkOPs.cpp:406
ripple::NetworkOPsImp::tryRemoveRpcSub
bool tryRemoveRpcSub(std::string const &strUrl) override
Definition: NetworkOPs.cpp:3481
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:2473
ripple::ValidatorList::setNegativeUNL
void setNegativeUNL(hash_set< PublicKey > const &negUnl)
set the Negative UNL with validators' master public keys
Definition: ValidatorList.cpp:997
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:480
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:210
ripple::LedgerMaster::getValidatedRules
Rules getValidatedRules()
Definition: LedgerMaster.cpp:1536
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:896
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:443
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:49
beast::Journal::warn
Stream warn() const
Definition: Journal.h:327
std::recursive_mutex
STL class.
ripple::keylet::child
Keylet child(uint256 const &key) noexcept
Any item that can be in an owner dir.
Definition: Indexes.cpp:127
ripple::NetworkOPsImp::consensusViewChange
void consensusViewChange() override
Definition: NetworkOPs.cpp:1867
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:1705
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:96
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:2856
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:1671
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:180
ripple::peer_in_set
Select all peers that are in the specified set.
Definition: predicates.h:160
ripple::RCLValidatedLedger
Wraps a ledger instance for use in generic Validations LedgerTrie.
Definition: RCLValidations.h:153
ripple::sfReserveBase
const SF_U32 sfReserveBase(access, STI_UINT32, 31, "ReserveBase")
Definition: SField.h: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:2255
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:1558
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:3379
std::unique_lock::unlock
T unlock(T... args)
ripple::Serializer::data
void const * data() const noexcept
Definition: Serializer.h:75
ripple::terQUEUED
@ terQUEUED
Definition: TER.h:198
ripple::NetworkOPsImp::StateAccounting::mutex_
std::mutex mutex_
Definition: NetworkOPs.cpp: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:1523
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:570
ripple::LoadFeeTrack::getRemoteFee
std::uint32_t getRemoteFee() const
Definition: LoadFeeTrack.h:66
ripple::jtBATCH
@ jtBATCH
Definition: Job.h:52
ripple::base_uint
Definition: base_uint.h:63
ripple::make_NetworkOPs
std::unique_ptr< NetworkOPs > make_NetworkOPs(Application &app, NetworkOPs::clock_type &clock, bool standalone, std::size_t minPeerCount, bool startvalid, JobQueue &job_queue, LedgerMaster &ledgerMaster, Stoppable &parent, ValidatorKeys const &validatorKeys, boost::asio::io_service &io_svc, beast::Journal journal, beast::insight::Collector::ptr const &collector)
Definition: NetworkOPs.cpp:3906
ripple::Manifest::getSignature
boost::optional< Blob > getSignature() const
Returns manifest signature.
Definition: app/misc/impl/Manifest.cpp:224
ripple::INCLUDED
@ INCLUDED
Definition: Transaction.h:46
ripple::RCLConsensus
Manages the generic consensus algorithm for use by the RCL.
Definition: RCLConsensus.h: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:3471
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:3881
ripple::OperatingMode::DISCONNECTED
@ DISCONNECTED
not ready to process requests
ripple::NetworkOPsImp::TransactionStatus::local
const bool local
Definition: NetworkOPs.cpp:83
ripple::Stoppable
Provides an interface for starting and stopping.
Definition: Stoppable.h:200
ripple::NetworkOPsImp::clearAmendmentWarned
void clearAmendmentWarned() override
Definition: NetworkOPs.cpp: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:1493
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:2924
ripple::LoadFeeTrack::getLocalFee
std::uint32_t getLocalFee() const
Definition: LoadFeeTrack.h:73
ripple::base_uint::isZero
bool isZero() const
Definition: base_uint.h:475
ripple::OperatingMode::CONNECTED
@ CONNECTED
convinced we are talking to the network
ripple::OBSOLETE
@ OBSOLETE
Definition: Transaction.h:51
ripple::Application::getLoadManager
virtual LoadManager & getLoadManager()=0
ripple::InfoSub::pointer
std::shared_ptr< InfoSub > pointer
Definition: InfoSub.h:49
Json::objectValue
@ objectValue
object value (collection of name/value pairs).
Definition: json_value.h:43
ripple::XRPAmount::decimalXRP
constexpr double decimalXRP() const
Definition: XRPAmount.h:247
ripple::NetworkOPsImp::hasTXSet
bool hasTXSet(const std::shared_ptr< Peer > &peer, uint256 const &set, protocol::TxSetStatus status)
ripple::Application::getLedgerMaster
virtual LedgerMaster & getLedgerMaster()=0
ripple::InboundLedgers::acquire
virtual std::shared_ptr< Ledger const > acquire(uint256 const &hash, std::uint32_t seq, InboundLedger::Reason)=0
ripple::RCLConsensus::peerProposal
bool peerProposal(NetClock::time_point const &now, RCLCxPeerPos const &newProposal)
Definition: RCLConsensus.cpp: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:3011
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:291
ripple::sfSigningTime
const SF_U32 sfSigningTime(access, STI_UINT32, 9, "SigningTime")
Definition: SField.h:361
ripple::NetworkOPsImp::endConsensus
void endConsensus() override
Definition: NetworkOPs.cpp:1811
std::unique_lock
STL class.
ripple::NetworkOPsImp::unsubAccount
void unsubAccount(InfoSub::ref ispListener, hash_set< AccountID > const &vnaAccountIDs, bool rt) override
Definition: NetworkOPs.cpp:3193
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:3397
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:2395
std::to_string
T to_string(T... args)
ripple::NetworkOPsImp::subManifests
bool subManifests(InfoSub::ref ispListener) override
Definition: NetworkOPs.cpp:3313
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:1336
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:2953
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:3062
ripple::LedgerMaster::getLedgerBySeq
std::shared_ptr< Ledger const > getLedgerBySeq(std::uint32_t index)
Definition: LedgerMaster.cpp:1669
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:3369
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:3305
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
boost::optional< std::set< PeerShortID > > shouldRelay(uint256 const &key)
Determines whether the hashed item should be relayed.
Definition: HashRouter.cpp:112
ripple::LedgerMaster::addHeldTransaction
void addHeldTransaction(std::shared_ptr< Transaction > const &trans)
Definition: LedgerMaster.cpp:399
ripple::Manifest::getMasterSignature
Blob getMasterSignature() const
Returns manifest master key signature.
Definition: app/misc/impl/Manifest.cpp:235
std::atomic< OperatingMode >
ripple::Overlay::foreach
void foreach(Function f) const
Visit every active peer.
Definition: Overlay.h:167
ripple::NetworkOPsImp::ServerFeeSummary::ServerFeeSummary
ServerFeeSummary()=default
ripple::NetworkOPsImp::StateAccounting::mode_
OperatingMode mode_
Definition: NetworkOPs.cpp: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:493
ripple::LoadFeeTrack::getClusterFee
std::uint32_t getClusterFee() const
Definition: LoadFeeTrack.h:80
ripple::NetworkOPs::NetworkOPs
NetworkOPs(Stoppable &parent)
Definition: NetworkOPs.cpp:3859
ripple::Application::getValidationPublicKey
virtual PublicKey const & getValidationPublicKey() const =0
ripple::NetworkOPsImp::pubValidation
void pubValidation(std::shared_ptr< STValidation > const &val) override
Definition: NetworkOPs.cpp:2047
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:2335
ripple::OrderBookDB::makeBookListeners
BookListeners::pointer makeBookListeners(Book const &)
Definition: OrderBookDB.cpp:216
ripple::NetworkOPs::FailHard
FailHard
Definition: NetworkOPs.h:96
ripple::TxQ::processClosedLedger
void processClosedLedger(Application &app, ReadView const &view, bool timeLeap)
Update fee metrics and clean up the queue in preparation for the next ledger.
Definition: TxQ.cpp:1130
ripple::NetworkOPsImp::subAccount
void subAccount(InfoSub::ref ispListener, hash_set< AccountID > const &vnaAccountIDs, bool rt) override
Definition: NetworkOPs.cpp:3156
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:1530
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:194
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:1923
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:2184
ripple::getJson
Json::Value getJson(LedgerFill const &fill)
Return a new Json::Value representing the ledger with given options.
Definition: LedgerToJson.cpp:283
ripple::NetworkOPsImp::sConsensusPhase
@ sConsensusPhase
Definition: NetworkOPs.cpp: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:284
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:188
ripple::NetworkOPsImp::reportConsensusStateChange
void reportConsensusStateChange(ConsensusPhase phase)
Definition: NetworkOPs.cpp:2942
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:178
ripple::NetworkOPsImp::unsubServer
bool unsubServer(std::uint64_t uListener) override
Definition: NetworkOPs.cpp:3361
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:515
ripple::Config::features
std::unordered_set< uint256, beast::uhash<> > features
Definition: Config.h:185
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:2817
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:45
ripple::Validity::Valid
@ Valid
Signature and local checks are good / passed.
ripple::NetworkOPsImp::pubServer
void pubServer()
Definition: NetworkOPs.cpp:1952
ripple::base_uint::begin
iterator begin()
Definition: base_uint.h:114
ripple::tefPAST_SEQ
@ tefPAST_SEQ
Definition: TER.h:151
ripple::NetworkOPsImp::unsubBook
bool unsubBook(std::uint64_t uListener, Book const &) override
Definition: NetworkOPs.cpp:3247
ripple::TransactionMaster::canonicalize
void canonicalize(std::shared_ptr< Transaction > *pTransaction)
Definition: TransactionMaster.cpp:132
ripple::NetworkOPsImp::sTransactions
@ sTransactions
Definition: NetworkOPs.cpp:744
ripple::NetworkOPsImp::mSubAccount
SubInfoMapType mSubAccount
Definition: NetworkOPs.cpp:735
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:1566
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:3506
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:2115
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:3276
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:3323
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:444
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:140
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:2020
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:3387
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:2496
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:3331
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:495
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:181
ripple::TxQ::getMetrics
Metrics getMetrics(OpenView const &view) const
Returns fee metrics in reference fee level units.
Definition: TxQ.cpp:1314
ripple::NetworkOPsImp::doTransactionSync
void doTransactionSync(std::shared_ptr< Transaction > transaction, bool bUnlimited, FailHard failType)
For transactions submitted directly by a client, apply batch of transactions and wait for this transa...
Definition: NetworkOPs.cpp: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:399
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:3237
ripple::NetworkOPsImp::subConsensus
bool subConsensus(InfoSub::ref ispListener) override
Definition: NetworkOPs.cpp:3441
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:2490
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:3867
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:3209
ripple::ReadView::succ
virtual boost::optional< key_type > succ(key_type const &key, boost::optional< key_type > const &last=boost::none) const =0
Return the key of the next state item.
ripple::tesSUCCESS
@ tesSUCCESS
Definition: TER.h:213
ripple::NetworkOPsImp::StateAccounting
State accounting records two attributes for each possible server state: 1) Amount of time spent in ea...
Definition: NetworkOPs.cpp: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:103
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:3433
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:96
ripple::handleNewValidation
void handleNewValidation(Application &app, std::shared_ptr< STValidation > const &val, std::string const &source)
Handle a new validation.
Definition: RCLValidations.cpp:152
ripple::isTemMalformed
bool isTemMalformed(TER x)
Definition: TER.h:558
ripple::trunc32
static std::uint32_t trunc32(std::uint64_t v)
Definition: NetworkOPs.cpp:1944
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:3458
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:2811
ripple::AccountIDCache::toBase58
std::string toBase58(AccountID const &) const
Return ripple::toBase58 for the AccountID.
Definition: AccountID.cpp:190
ripple::RCLConsensus::simulate
void simulate(NetClock::time_point const &now, boost::optional< std::chrono::milliseconds > consensusDelay)
Definition: RCLConsensus.cpp: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:1725
ripple::NetworkOPsImp::setAmendmentBlocked
void setAmendmentBlocked() override
Definition: NetworkOPs.cpp:1559
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)