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