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