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