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