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