rippled
Application.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/RCLValidations.h>
21 #include <ripple/app/ledger/InboundLedgers.h>
22 #include <ripple/app/ledger/InboundTransactions.h>
23 #include <ripple/app/ledger/LedgerMaster.h>
24 #include <ripple/app/ledger/LedgerToJson.h>
25 #include <ripple/app/ledger/OpenLedger.h>
26 #include <ripple/app/ledger/OrderBookDB.h>
27 #include <ripple/app/ledger/PendingSaves.h>
28 #include <ripple/app/ledger/TransactionMaster.h>
29 #include <ripple/app/main/Application.h>
30 #include <ripple/app/main/BasicApp.h>
31 #include <ripple/app/main/DBInit.h>
32 #include <ripple/app/main/LoadManager.h>
33 #include <ripple/app/main/NodeIdentity.h>
34 #include <ripple/app/main/NodeStoreScheduler.h>
35 #include <ripple/app/main/Tuning.h>
36 #include <ripple/app/misc/AmendmentTable.h>
37 #include <ripple/app/misc/HashRouter.h>
38 #include <ripple/app/misc/LoadFeeTrack.h>
39 #include <ripple/app/misc/NetworkOPs.h>
40 #include <ripple/app/misc/SHAMapStore.h>
41 #include <ripple/app/misc/TxQ.h>
42 #include <ripple/app/misc/ValidatorKeys.h>
43 #include <ripple/app/misc/ValidatorSite.h>
44 #include <ripple/app/paths/PathRequests.h>
45 #include <ripple/app/tx/apply.h>
46 #include <ripple/basics/ByteUtilities.h>
47 #include <ripple/basics/PerfLog.h>
48 #include <ripple/basics/ResolverAsio.h>
49 #include <ripple/basics/safe_cast.h>
50 #include <ripple/beast/asio/io_latency_probe.h>
51 #include <ripple/beast/core/LexicalCast.h>
52 #include <ripple/core/DatabaseCon.h>
53 #include <ripple/core/Stoppable.h>
54 #include <ripple/json/json_reader.h>
55 #include <ripple/nodestore/DatabaseShard.h>
56 #include <ripple/nodestore/DummyScheduler.h>
57 #include <ripple/overlay/Cluster.h>
58 #include <ripple/overlay/PeerReservationTable.h>
59 #include <ripple/overlay/make_Overlay.h>
60 #include <ripple/protocol/BuildInfo.h>
61 #include <ripple/protocol/Feature.h>
62 #include <ripple/protocol/Protocol.h>
63 #include <ripple/protocol/STParsedJSON.h>
64 #include <ripple/resource/Fees.h>
65 #include <ripple/rpc/ShardArchiveHandler.h>
66 #include <ripple/rpc/impl/RPCHelpers.h>
67 
68 #include <ripple/app/main/GRPCServer.h>
69 #include <boost/algorithm/string/predicate.hpp>
70 #include <boost/asio/steady_timer.hpp>
71 #include <boost/system/error_code.hpp>
72 
73 #include <condition_variable>
74 #include <cstring>
75 #include <iostream>
76 #include <mutex>
77 
78 namespace ripple {
79 
80 // 204/256 about 80%
81 static int const MAJORITY_FRACTION(204);
82 
83 //------------------------------------------------------------------------------
84 
85 namespace detail {
86 
87 class AppFamily : public Family
88 {
89 private:
94  bool const shardBacked_;
96 
97  // missing node handler
100 
101  void
102  acquire(uint256 const& hash, std::uint32_t seq)
103  {
104  if (hash.isNonZero())
105  {
106  auto j = app_.journal("Ledger");
107 
108  JLOG(j.error()) << "Missing node in " << to_string(hash);
109 
111  hash,
112  seq,
115  }
116  }
117 
118 public:
119  AppFamily(AppFamily const&) = delete;
120  AppFamily&
121  operator=(AppFamily const&) = delete;
122 
124  Application& app,
126  CollectorManager& collectorManager)
127  : app_(app)
128  , treecache_(
129  "TreeNodeCache",
130  65536,
131  std::chrono::minutes{1},
132  stopwatch(),
133  app.journal("TaggedCache"))
134  , fullbelow_(
135  "full_below",
136  stopwatch(),
137  collectorManager.collector(),
140  , db_(db)
141  , shardBacked_(dynamic_cast<NodeStore::DatabaseShard*>(&db) != nullptr)
142  , j_(app.journal("SHAMap"))
143  {
144  }
145 
146  beast::Journal const&
147  journal() override
148  {
149  return j_;
150  }
151 
153  fullbelow() override
154  {
155  return fullbelow_;
156  }
157 
158  FullBelowCache const&
159  fullbelow() const override
160  {
161  return fullbelow_;
162  }
163 
165  treecache() override
166  {
167  return treecache_;
168  }
169 
170  TreeNodeCache const&
171  treecache() const override
172  {
173  return treecache_;
174  }
175 
177  db() override
178  {
179  return db_;
180  }
181 
182  NodeStore::Database const&
183  db() const override
184  {
185  return db_;
186  }
187 
188  bool
189  isShardBacked() const override
190  {
191  return shardBacked_;
192  }
193 
194  void
196  {
197  auto j = app_.journal("Ledger");
198 
199  JLOG(j.error()) << "Missing node in " << seq;
200 
201  // prevent recursive invocation
203 
204  if (maxSeq == 0)
205  {
206  maxSeq = seq;
207 
208  do
209  {
210  // Try to acquire the most recent missing ledger
211  seq = maxSeq;
212 
213  lock.unlock();
214 
215  // This can invoke the missing node handler
217 
218  lock.lock();
219  } while (maxSeq != seq);
220  }
221  else if (maxSeq < seq)
222  {
223  // We found a more recent ledger with a
224  // missing node
225  maxSeq = seq;
226  }
227  }
228 
229  void
230  missing_node(uint256 const& hash, std::uint32_t seq) override
231  {
232  acquire(hash, seq);
233  }
234 
235  void
236  reset() override
237  {
238  {
240  maxSeq = 0;
241  }
242  fullbelow_.reset();
243  treecache_.reset();
244  }
245 };
246 
247 } // namespace detail
248 
249 //------------------------------------------------------------------------------
250 
251 // VFALCO TODO Move the function definitions into the class declaration
252 class ApplicationImp : public Application, public RootStoppable, public BasicApp
253 {
254 private:
256  {
257  private:
262 
263  public:
267  std::chrono::milliseconds interval,
268  boost::asio::io_service& ios)
269  : m_event(ev)
270  , m_journal(journal)
271  , m_probe(interval, ios)
272  , lastSample_{}
273  {
274  }
275 
276  void
278  {
279  m_probe.sample(std::ref(*this));
280  }
281 
282  template <class Duration>
283  void
284  operator()(Duration const& elapsed)
285  {
286  using namespace std::chrono;
287  auto const lastSample = date::ceil<milliseconds>(elapsed);
288 
289  lastSample_ = lastSample;
290 
291  if (lastSample >= 10ms)
292  m_event.notify(lastSample);
293  if (lastSample >= 500ms)
294  {
295  JLOG(m_journal.warn())
296  << "io_service latency = " << lastSample.count();
297  }
298  }
299 
301  get() const
302  {
303  return lastSample_.load();
304  }
305 
306  void
308  {
309  m_probe.cancel();
310  }
311 
312  void
314  {
316  }
317  };
318 
319 public:
323 
327 
328  // Required by the SHAMapStore
330 
335  boost::optional<OpenLedger> openLedger_;
336 
337  // These are not Stoppable-derived
343 
345 
346  // These are Stoppable-related
352  // VFALCO TODO Make OrderBookDB abstract
374  boost::asio::steady_timer sweepTimer_;
375  boost::asio::steady_timer entropyTimer_;
377 
383 
384  boost::asio::signal_set m_signals;
385 
388  bool isTimeToStop = false;
389 
391 
393 
395 
397 
398  //--------------------------------------------------------------------------
399 
400  static std::size_t
402  {
403 #if RIPPLE_SINGLE_IO_SERVICE_THREAD
404  return 1;
405 #else
406  auto const cores = std::thread::hardware_concurrency();
407 
408  // Use a single thread when running on under-provisioned systems
409  // or if we are configured to use minimal resources.
410  if ((cores == 1) || ((config.NODE_SIZE == 0) && (cores == 2)))
411  return 1;
412 
413  // Otherwise, prefer two threads.
414  return 2;
415 #endif
416  }
417 
418  //--------------------------------------------------------------------------
419 
424  : RootStoppable("Application")
426  , config_(std::move(config))
427  , logs_(std::move(logs))
428  , timeKeeper_(std::move(timeKeeper))
429  , m_journal(logs_->journal("Application"))
430 
431  // PerfLog must be started before any other threads are launched.
432  , perfLog_(perf::make_PerfLog(
433  perf::setup_PerfLog(
434  config_->section("perf"),
435  config_->CONFIG_DIR),
436  *this,
437  logs_->journal("PerfLog"),
438  [this]() { signalStop(); }))
439 
440  , m_txMaster(*this)
441 
442  , m_nodeStoreScheduler(*this)
443 
445  *this,
446  *this,
448  logs_->journal("SHAMapStore")))
449 
450  , accountIDCache_(128000)
451 
452  , m_tempNodeCache(
453  "NodeCache",
454  16384,
456  stopwatch(),
457  logs_->journal("TaggedCache"))
458 
460  config_->section(SECTION_INSIGHT),
461  logs_->journal("Collector")))
464 
466  m_collectorManager->collector(),
467  logs_->journal("Resource")))
468 
469  // The JobQueue has to come pretty early since
470  // almost everything is a Stoppable child of the JobQueue.
471  //
472  , m_jobQueue(std::make_unique<JobQueue>(
473  m_collectorManager->group("jobq"),
475  logs_->journal("JobQueue"),
476  *logs_,
477  *perfLog_))
478 
479  , m_nodeStore(m_shaMapStore->makeNodeStore("NodeStore.main", 4))
480 
482 
483  // The shard store is optional and make_ShardStore can return null.
484  , shardStore_(make_ShardStore(
485  *this,
486  *m_jobQueue,
488  4,
489  logs_->journal("ShardStore")))
490 
491  , m_orderBookDB(*this, *m_jobQueue)
492 
493  , m_pathRequests(std::make_unique<PathRequests>(
494  *this,
495  logs_->journal("PathRequest"),
496  m_collectorManager->collector()))
497 
498  , m_ledgerMaster(std::make_unique<LedgerMaster>(
499  *this,
500  stopwatch(),
501  *m_jobQueue,
502  m_collectorManager->collector(),
503  logs_->journal("LedgerMaster")))
504 
505  // VFALCO NOTE must come before NetworkOPs to prevent a crash due
506  // to dependencies in the destructor.
507  //
509  *this,
510  stopwatch(),
511  *m_jobQueue,
512  m_collectorManager->collector()))
513 
515  *this,
516  *m_jobQueue,
517  m_collectorManager->collector(),
518  [this](std::shared_ptr<SHAMap> const& set, bool fromAcquire) {
519  gotTXSet(set, fromAcquire);
520  }))
521 
523  "AcceptedLedger",
524  4,
526  stopwatch(),
527  logs_->journal("TaggedCache"))
528 
530  *this,
531  stopwatch(),
532  config_->standalone(),
533  config_->NETWORK_QUORUM,
534  config_->START_VALID,
535  *m_jobQueue,
537  *m_jobQueue,
539  get_io_service(),
540  logs_->journal("NetworkOPs"),
541  m_collectorManager->collector()))
542 
543  , cluster_(std::make_unique<Cluster>(logs_->journal("Overlay")))
544 
545  , peerReservations_(std::make_unique<PeerReservationTable>(
546  logs_->journal("PeerReservationTable")))
547 
549  std::make_unique<ManifestCache>(logs_->journal("ManifestCache")))
550 
552  std::make_unique<ManifestCache>(logs_->journal("ManifestCache")))
553 
554  , validators_(std::make_unique<ValidatorList>(
557  *timeKeeper_,
558  config_->legacy("database_path"),
559  logs_->journal("ValidatorList"),
560  config_->VALIDATION_QUORUM))
561 
562  , validatorSites_(std::make_unique<ValidatorSite>(*this))
563 
565  *this,
566  *m_networkOPs,
567  get_io_service(),
568  *m_jobQueue,
569  *m_networkOPs,
572 
573  , mFeeTrack(
574  std::make_unique<LoadFeeTrack>(logs_->journal("LoadManager")))
575 
576  , hashRouter_(std::make_unique<HashRouter>(
577  stopwatch(),
580 
581  , mValidations(
582  ValidationParms(),
583  stopwatch(),
584  *this,
585  logs_->journal("Validations"))
586 
587  , m_loadManager(
588  make_LoadManager(*this, *this, logs_->journal("LoadManager")))
589 
590  , txQ_(make_TxQ(setup_TxQ(*config_), logs_->journal("TxQ")))
591 
593 
595 
596  , startTimers_(false)
597 
599 
600  , checkSigs_(true)
601 
602  , m_resolver(
603  ResolverAsio::New(get_io_service(), logs_->journal("Resolver")))
604 
606  m_collectorManager->collector()->make_event("ios_latency"),
607  logs_->journal("Application"),
609  get_io_service())
610  , grpcServer_(std::make_unique<GRPCServer>(*this))
611  {
612  add(m_resourceManager.get());
613 
614  //
615  // VFALCO - READ THIS!
616  //
617  // Do not start threads, open sockets, or do any sort of "real work"
618  // inside the constructor. Put it in onStart instead. Or if you must,
619  // put it in setup (but everything in setup should be moved to onStart
620  // anyway.
621  //
622  // The reason is that the unit tests require an Application object to
623  // be created. But we don't actually start all the threads, sockets,
624  // and services when running the unit tests. Therefore anything which
625  // needs to be stopped will not get stopped correctly if it is
626  // started in this constructor.
627  //
628 
629  // VFALCO HACK
631 
632  add(m_ledgerMaster->getPropertySource());
633  }
634 
635  //--------------------------------------------------------------------------
636 
637  bool
638  setup() override;
639  void
640  doStart(bool withTimers) override;
641  void
642  run() override;
643  bool
644  isShutdown() override;
645  void
646  signalStop() override;
647  bool
648  checkSigs() const override;
649  void
650  checkSigs(bool) override;
651  int
652  fdRequired() const override;
653 
654  //--------------------------------------------------------------------------
655 
656  Logs&
657  logs() override
658  {
659  return *logs_;
660  }
661 
662  Config&
663  config() override
664  {
665  return *config_;
666  }
667 
670  {
671  return *m_collectorManager;
672  }
673 
674  Family&
675  family() override
676  {
677  return family_;
678  }
679 
680  Family*
681  shardFamily() override
682  {
683  return shardFamily_.get();
684  }
685 
686  TimeKeeper&
687  timeKeeper() override
688  {
689  return *timeKeeper_;
690  }
691 
692  JobQueue&
693  getJobQueue() override
694  {
695  return *m_jobQueue;
696  }
697 
699  nodeIdentity() override
700  {
701  return nodeIdentity_;
702  }
703 
704  PublicKey const&
705  getValidationPublicKey() const override
706  {
707  return validatorKeys_.publicKey;
708  }
709 
710  NetworkOPs&
711  getOPs() override
712  {
713  return *m_networkOPs;
714  }
715 
716  boost::asio::io_service&
717  getIOService() override
718  {
719  return get_io_service();
720  }
721 
723  getIOLatency() override
724  {
725  return m_io_latency_sampler.get();
726  }
727 
728  LedgerMaster&
729  getLedgerMaster() override
730  {
731  return *m_ledgerMaster;
732  }
733 
735  getInboundLedgers() override
736  {
737  return *m_inboundLedgers;
738  }
739 
742  {
743  return *m_inboundTransactions;
744  }
745 
748  {
749  return m_acceptedLedgerCache;
750  }
751 
752  void
753  gotTXSet(std::shared_ptr<SHAMap> const& set, bool fromAcquire)
754  {
755  if (set)
756  m_networkOPs->mapComplete(set, fromAcquire);
757  }
758 
761  {
762  return m_txMaster;
763  }
764 
766  getPerfLog() override
767  {
768  return *perfLog_;
769  }
770 
771  NodeCache&
772  getTempNodeCache() override
773  {
774  return m_tempNodeCache;
775  }
776 
778  getNodeStore() override
779  {
780  return *m_nodeStore;
781  }
782 
784  getShardStore() override
785  {
786  return shardStore_.get();
787  }
788 
790  getMasterMutex() override
791  {
792  return m_masterMutex;
793  }
794 
795  LoadManager&
796  getLoadManager() override
797  {
798  return *m_loadManager;
799  }
800 
803  {
804  return *m_resourceManager;
805  }
806 
807  OrderBookDB&
808  getOrderBookDB() override
809  {
810  return m_orderBookDB;
811  }
812 
813  PathRequests&
814  getPathRequests() override
815  {
816  return *m_pathRequests;
817  }
818 
819  CachedSLEs&
820  cachedSLEs() override
821  {
822  return cachedSLEs_;
823  }
824 
826  getAmendmentTable() override
827  {
828  return *m_amendmentTable;
829  }
830 
831  LoadFeeTrack&
832  getFeeTrack() override
833  {
834  return *mFeeTrack;
835  }
836 
837  HashRouter&
838  getHashRouter() override
839  {
840  return *hashRouter_;
841  }
842 
844  getValidations() override
845  {
846  return mValidations;
847  }
848 
850  validators() override
851  {
852  return *validators_;
853  }
854 
856  validatorSites() override
857  {
858  return *validatorSites_;
859  }
860 
863  {
864  return *validatorManifests_;
865  }
866 
869  {
870  return *publisherManifests_;
871  }
872 
873  Cluster&
874  cluster() override
875  {
876  return *cluster_;
877  }
878 
880  peerReservations() override
881  {
882  return *peerReservations_;
883  }
884 
885  SHAMapStore&
886  getSHAMapStore() override
887  {
888  return *m_shaMapStore;
889  }
890 
891  PendingSaves&
892  pendingSaves() override
893  {
894  return pendingSaves_;
895  }
896 
897  AccountIDCache const&
898  accountIDCache() const override
899  {
900  return accountIDCache_;
901  }
902 
903  OpenLedger&
904  openLedger() override
905  {
906  return *openLedger_;
907  }
908 
909  OpenLedger const&
910  openLedger() const override
911  {
912  return *openLedger_;
913  }
914 
915  Overlay&
916  overlay() override
917  {
918  assert(overlay_);
919  return *overlay_;
920  }
921 
922  TxQ&
923  getTxQ() override
924  {
925  assert(txQ_.get() != nullptr);
926  return *txQ_;
927  }
928 
929  DatabaseCon&
930  getTxnDB() override
931  {
932  assert(mTxnDB.get() != nullptr);
933  return *mTxnDB;
934  }
935  DatabaseCon&
936  getLedgerDB() override
937  {
938  assert(mLedgerDB.get() != nullptr);
939  return *mLedgerDB;
940  }
941  DatabaseCon&
942  getWalletDB() override
943  {
944  assert(mWalletDB.get() != nullptr);
945  return *mWalletDB;
946  }
947 
948  bool
949  serverOkay(std::string& reason) override;
950 
952  journal(std::string const& name) override;
953 
954  //--------------------------------------------------------------------------
955 
956  bool
958  {
959  assert(mTxnDB.get() == nullptr);
960  assert(mLedgerDB.get() == nullptr);
961  assert(mWalletDB.get() == nullptr);
962 
963  try
964  {
965  auto const setup = setup_DatabaseCon(*config_);
966 
967  // transaction database
968  mTxnDB = std::make_unique<DatabaseCon>(
970  mTxnDB->getSession() << boost::str(
971  boost::format("PRAGMA cache_size=-%d;") %
972  kilobytes(config_->getValueFor(SizedItem::txnDBCache)));
973  mTxnDB->setupCheckpointing(m_jobQueue.get(), logs());
974 
975  if (!setup.standAlone || setup.startUp == Config::LOAD ||
976  setup.startUp == Config::LOAD_FILE ||
977  setup.startUp == Config::REPLAY)
978  {
979  // Check if AccountTransactions has primary key
980  std::string cid, name, type;
981  std::size_t notnull, dflt_value, pk;
982  soci::indicator ind;
983  soci::statement st =
984  (mTxnDB->getSession().prepare
985  << ("PRAGMA table_info(AccountTransactions);"),
986  soci::into(cid),
987  soci::into(name),
988  soci::into(type),
989  soci::into(notnull),
990  soci::into(dflt_value, ind),
991  soci::into(pk));
992 
993  st.execute();
994  while (st.fetch())
995  {
996  if (pk == 1)
997  {
998  JLOG(m_journal.fatal())
999  << "AccountTransactions database "
1000  "should not have a primary key";
1001  return false;
1002  }
1003  }
1004  }
1005 
1006  // ledger database
1007  mLedgerDB = std::make_unique<DatabaseCon>(
1009  mLedgerDB->getSession() << boost::str(
1010  boost::format("PRAGMA cache_size=-%d;") %
1011  kilobytes(config_->getValueFor(SizedItem::lgrDBCache)));
1012  mLedgerDB->setupCheckpointing(m_jobQueue.get(), logs());
1013 
1014  // wallet database
1015  mWalletDB = std::make_unique<DatabaseCon>(
1016  setup,
1017  WalletDBName,
1019  WalletDBInit);
1020  }
1021  catch (std::exception const& e)
1022  {
1023  JLOG(m_journal.fatal())
1024  << "Failed to initialize SQLite databases: " << e.what();
1025  return false;
1026  }
1027 
1028  return true;
1029  }
1030 
1031  bool
1033  {
1034  if (config_->doImport)
1035  {
1036  auto j = logs_->journal("NodeObject");
1037  NodeStore::DummyScheduler dummyScheduler;
1038  RootStoppable dummyRoot{"DummyRoot"};
1041  "NodeStore.import",
1042  dummyScheduler,
1043  0,
1044  dummyRoot,
1046  j);
1047 
1048  JLOG(j.warn()) << "Starting node import from '" << source->getName()
1049  << "' to '" << m_nodeStore->getName() << "'.";
1050 
1051  using namespace std::chrono;
1052  auto const start = steady_clock::now();
1053 
1054  m_nodeStore->import(*source);
1055 
1056  auto const elapsed =
1057  duration_cast<seconds>(steady_clock::now() - start);
1058  JLOG(j.warn()) << "Node import from '" << source->getName()
1059  << "' took " << elapsed.count() << " seconds.";
1060  }
1061 
1062  // tune caches
1063  using namespace std::chrono;
1064  m_nodeStore->tune(
1065  config_->getValueFor(SizedItem::nodeCacheSize),
1066  seconds{config_->getValueFor(SizedItem::nodeCacheAge)});
1067 
1068  m_ledgerMaster->tune(
1069  config_->getValueFor(SizedItem::ledgerSize),
1070  seconds{config_->getValueFor(SizedItem::ledgerAge)});
1071 
1073  config_->getValueFor(SizedItem::treeCacheSize));
1075  seconds{config_->getValueFor(SizedItem::treeCacheAge)});
1076 
1077  return true;
1078  }
1079 
1080  //--------------------------------------------------------------------------
1081  //
1082  // Stoppable
1083  //
1084 
1085  void
1086  onPrepare() override
1087  {
1088  }
1089 
1090  void
1091  onStart() override
1092  {
1093  JLOG(m_journal.info()) << "Application starting. Version is "
1095 
1096  using namespace std::chrono_literals;
1097  if (startTimers_)
1098  {
1099  setSweepTimer();
1100  setEntropyTimer();
1101  }
1102 
1104 
1105  m_resolver->start();
1106  }
1107 
1108  // Called to indicate shutdown.
1109  void
1110  onStop() override
1111  {
1112  JLOG(m_journal.debug()) << "Application stopping";
1113 
1115 
1116  // VFALCO Enormous hack, we have to force the probe to cancel
1117  // before we stop the io_service queue or else it never
1118  // unblocks in its destructor. The fix is to make all
1119  // io_objects gracefully handle exit so that we can
1120  // naturally return from io_service::run() instead of
1121  // forcing a call to io_service::stop()
1123 
1124  m_resolver->stop_async();
1125 
1126  // NIKB This is a hack - we need to wait for the resolver to
1127  // stop. before we stop the io_server_queue or weird
1128  // things will happen.
1129  m_resolver->stop();
1130 
1131  {
1132  boost::system::error_code ec;
1133  sweepTimer_.cancel(ec);
1134  if (ec)
1135  {
1136  JLOG(m_journal.error())
1137  << "Application: sweepTimer cancel error: " << ec.message();
1138  }
1139 
1140  ec.clear();
1141  entropyTimer_.cancel(ec);
1142  if (ec)
1143  {
1144  JLOG(m_journal.error())
1145  << "Application: entropyTimer cancel error: "
1146  << ec.message();
1147  }
1148  }
1149  // Make sure that any waitHandlers pending in our timers are done
1150  // before we declare ourselves stopped.
1151  using namespace std::chrono_literals;
1152  waitHandlerCounter_.join("Application", 1s, m_journal);
1153 
1154  mValidations.flush();
1155 
1156  validatorSites_->stop();
1157 
1158  // TODO Store manifests in manifests.sqlite instead of wallet.db
1159  validatorManifests_->save(
1160  getWalletDB(),
1161  "ValidatorManifests",
1162  [this](PublicKey const& pubKey) {
1163  return validators().listed(pubKey);
1164  });
1165 
1166  publisherManifests_->save(
1167  getWalletDB(),
1168  "PublisherManifests",
1169  [this](PublicKey const& pubKey) {
1170  return validators().trustedPublisher(pubKey);
1171  });
1172 
1173  stopped();
1174  }
1175 
1176  //--------------------------------------------------------------------------
1177  //
1178  // PropertyStream
1179  //
1180 
1181  void
1183  {
1184  }
1185 
1186  //--------------------------------------------------------------------------
1187 
1188  void
1190  {
1191  // Only start the timer if waitHandlerCounter_ is not yet joined.
1192  if (auto optionalCountedHandler = waitHandlerCounter_.wrap(
1193  [this](boost::system::error_code const& e) {
1194  if ((e.value() == boost::system::errc::success) &&
1195  (!m_jobQueue->isStopped()))
1196  {
1197  m_jobQueue->addJob(
1198  jtSWEEP, "sweep", [this](Job&) { doSweep(); });
1199  }
1200  // Recover as best we can if an unexpected error occurs.
1201  if (e.value() != boost::system::errc::success &&
1202  e.value() != boost::asio::error::operation_aborted)
1203  {
1204  // Try again later and hope for the best.
1205  JLOG(m_journal.error())
1206  << "Sweep timer got error '" << e.message()
1207  << "'. Restarting timer.";
1208  setSweepTimer();
1209  }
1210  }))
1211  {
1212  using namespace std::chrono;
1213  sweepTimer_.expires_from_now(
1214  seconds{config_->getValueFor(SizedItem::sweepInterval)});
1215  sweepTimer_.async_wait(std::move(*optionalCountedHandler));
1216  }
1217  }
1218 
1219  void
1221  {
1222  // Only start the timer if waitHandlerCounter_ is not yet joined.
1223  if (auto optionalCountedHandler = waitHandlerCounter_.wrap(
1224  [this](boost::system::error_code const& e) {
1225  if (e.value() == boost::system::errc::success)
1226  {
1227  crypto_prng().mix_entropy();
1228  setEntropyTimer();
1229  }
1230  // Recover as best we can if an unexpected error occurs.
1231  if (e.value() != boost::system::errc::success &&
1232  e.value() != boost::asio::error::operation_aborted)
1233  {
1234  // Try again later and hope for the best.
1235  JLOG(m_journal.error())
1236  << "Entropy timer got error '" << e.message()
1237  << "'. Restarting timer.";
1238  setEntropyTimer();
1239  }
1240  }))
1241  {
1242  using namespace std::chrono_literals;
1243  entropyTimer_.expires_from_now(5min);
1244  entropyTimer_.async_wait(std::move(*optionalCountedHandler));
1245  }
1246  }
1247 
1248  void
1250  {
1251  if (!config_->standalone())
1252  {
1253  boost::filesystem::space_info space =
1254  boost::filesystem::space(config_->legacy("database_path"));
1255 
1256  if (space.available < megabytes(512))
1257  {
1258  JLOG(m_journal.fatal())
1259  << "Remaining free disk space is less than 512MB";
1260  signalStop();
1261  }
1262 
1264  boost::filesystem::path dbPath = dbSetup.dataDir / TxDBName;
1265  boost::system::error_code ec;
1266  boost::optional<std::uint64_t> dbSize =
1267  boost::filesystem::file_size(dbPath, ec);
1268  if (ec)
1269  {
1270  JLOG(m_journal.error())
1271  << "Error checking transaction db file size: "
1272  << ec.message();
1273  dbSize.reset();
1274  }
1275 
1276  auto db = mTxnDB->checkoutDb();
1277  static auto const pageSize = [&] {
1278  std::uint32_t ps;
1279  *db << "PRAGMA page_size;", soci::into(ps);
1280  return ps;
1281  }();
1282  static auto const maxPages = [&] {
1283  std::uint32_t mp;
1284  *db << "PRAGMA max_page_count;", soci::into(mp);
1285  return mp;
1286  }();
1287  std::uint32_t pageCount;
1288  *db << "PRAGMA page_count;", soci::into(pageCount);
1289  std::uint32_t freePages = maxPages - pageCount;
1290  std::uint64_t freeSpace =
1291  safe_cast<std::uint64_t>(freePages) * pageSize;
1292  JLOG(m_journal.info())
1293  << "Transaction DB pathname: " << dbPath.string()
1294  << "; file size: " << dbSize.value_or(-1) << " bytes"
1295  << "; SQLite page size: " << pageSize << " bytes"
1296  << "; Free pages: " << freePages
1297  << "; Free space: " << freeSpace << " bytes; "
1298  << "Note that this does not take into account available disk "
1299  "space.";
1300 
1301  if (freeSpace < megabytes(512))
1302  {
1303  JLOG(m_journal.fatal())
1304  << "Free SQLite space for transaction db is less than "
1305  "512MB. To fix this, rippled must be executed with the "
1306  "vacuum <sqlitetmpdir> parameter before restarting. "
1307  "Note that this activity can take multiple days, "
1308  "depending on database size.";
1309  signalStop();
1310  }
1311  }
1312 
1313  // VFALCO NOTE Does the order of calls matter?
1314  // VFALCO TODO fix the dependency inversion using an observer,
1315  // have listeners register for "onSweep ()" notification.
1316 
1317  family().fullbelow().sweep();
1318  if (shardFamily_)
1319  shardFamily_->fullbelow().sweep();
1321  getNodeStore().sweep();
1322  if (shardStore_)
1323  shardStore_->sweep();
1324  getLedgerMaster().sweep();
1325  getTempNodeCache().sweep();
1326  getValidations().expire();
1328  m_acceptedLedgerCache.sweep();
1329  family().treecache().sweep();
1330  if (shardFamily_)
1331  shardFamily_->treecache().sweep();
1332  cachedSLEs_.expire();
1333 
1334  // Set timer to do another sweep later.
1335  setSweepTimer();
1336  }
1337 
1338  LedgerIndex
1340  {
1341  return maxDisallowedLedger_;
1342  }
1343 
1344 private:
1345  // For a newly-started validator, this is the greatest persisted ledger
1346  // and new validations must be greater than this.
1348 
1349  bool
1350  nodeToShards();
1351  bool
1352  validateShards();
1353  void
1355 
1358 
1360  loadLedgerFromFile(std::string const& ledgerID);
1361 
1362  bool
1363  loadOldLedger(std::string const& ledgerID, bool replay, bool isFilename);
1364 
1365  void
1367 };
1368 
1369 //------------------------------------------------------------------------------
1370 
1371 // TODO Break this up into smaller, more digestible initialization segments.
1372 bool
1374 {
1375  // We want to intercept CTRL-C and the standard termination signal SIGTERM
1376  // and terminate the process. This handler will NEVER be invoked twice.
1377  //
1378  // Note that async_wait is "one-shot": for each call, the handler will be
1379  // invoked exactly once, either when one of the registered signals in the
1380  // signal set occurs or the signal set is cancelled. Subsequent signals are
1381  // effectively ignored (technically, they are queued up, waiting for a call
1382  // to async_wait).
1383  m_signals.add(SIGINT);
1384  m_signals.add(SIGTERM);
1385  m_signals.async_wait(
1386  [this](boost::system::error_code const& ec, int signum) {
1387  // Indicates the signal handler has been aborted; do nothing
1388  if (ec == boost::asio::error::operation_aborted)
1389  return;
1390 
1391  JLOG(m_journal.info()) << "Received signal " << signum;
1392 
1393  if (signum == SIGTERM || signum == SIGINT)
1394  signalStop();
1395  });
1396 
1397  assert(mTxnDB == nullptr);
1398 
1399  auto debug_log = config_->getDebugLogFile();
1400 
1401  if (!debug_log.empty())
1402  {
1403  // Let debug messages go to the file but only WARNING or higher to
1404  // regular output (unless verbose)
1405 
1406  if (!logs_->open(debug_log))
1407  std::cerr << "Can't open log file " << debug_log << '\n';
1408 
1409  using namespace beast::severities;
1410  if (logs_->threshold() > kDebug)
1411  logs_->threshold(kDebug);
1412  }
1413  JLOG(m_journal.info()) << "process starting: "
1415 
1416  if (numberOfThreads(*config_) < 2)
1417  {
1418  JLOG(m_journal.warn()) << "Limited to a single I/O service thread by "
1419  "system configuration.";
1420  }
1421 
1422  // Optionally turn off logging to console.
1423  logs_->silent(config_->silent());
1424 
1425  m_jobQueue->setThreadCount(config_->WORKERS, config_->standalone());
1426  grpcServer_->run();
1427 
1428  if (!config_->standalone())
1429  timeKeeper_->run(config_->SNTP_SERVERS);
1430 
1431  if (!initSQLiteDBs() || !initNodeStore())
1432  return false;
1433 
1434  if (shardStore_)
1435  {
1436  shardFamily_ = std::make_unique<detail::AppFamily>(
1437  *this, *shardStore_, *m_collectorManager);
1438 
1439  using namespace std::chrono;
1440  shardFamily_->treecache().setTargetSize(
1441  config_->getValueFor(SizedItem::treeCacheSize));
1442  shardFamily_->treecache().setTargetAge(
1443  seconds{config_->getValueFor(SizedItem::treeCacheAge)});
1444 
1445  if (!shardStore_->init())
1446  return false;
1447  }
1448 
1449  if (!peerReservations_->load(getWalletDB()))
1450  {
1451  JLOG(m_journal.fatal()) << "Cannot find peer reservations!";
1452  return false;
1453  }
1454 
1457 
1458  // Configure the amendments the server supports
1459  {
1460  auto const& sa = detail::supportedAmendments();
1461  std::vector<std::string> saHashes;
1462  saHashes.reserve(sa.size());
1463  for (auto const& name : sa)
1464  {
1465  auto const f = getRegisteredFeature(name);
1466  BOOST_ASSERT(f);
1467  if (f)
1468  saHashes.push_back(to_string(*f) + " " + name);
1469  }
1470  Section supportedAmendments("Supported Amendments");
1471  supportedAmendments.append(saHashes);
1472 
1473  Section enabledAmendments = config_->section(SECTION_AMENDMENTS);
1474 
1476  weeks{2},
1478  supportedAmendments,
1479  enabledAmendments,
1480  config_->section(SECTION_VETO_AMENDMENTS),
1481  logs_->journal("Amendments"));
1482  }
1483 
1485 
1486  auto const startUp = config_->START_UP;
1487  if (startUp == Config::FRESH)
1488  {
1489  JLOG(m_journal.info()) << "Starting new Ledger";
1490 
1492  }
1493  else if (
1494  startUp == Config::LOAD || startUp == Config::LOAD_FILE ||
1495  startUp == Config::REPLAY)
1496  {
1497  JLOG(m_journal.info()) << "Loading specified Ledger";
1498 
1499  if (!loadOldLedger(
1500  config_->START_LEDGER,
1501  startUp == Config::REPLAY,
1502  startUp == Config::LOAD_FILE))
1503  {
1504  JLOG(m_journal.error())
1505  << "The specified ledger could not be loaded.";
1506  return false;
1507  }
1508  }
1509  else if (startUp == Config::NETWORK)
1510  {
1511  // This should probably become the default once we have a stable
1512  // network.
1513  if (!config_->standalone())
1514  m_networkOPs->setNeedNetworkLedger();
1515 
1517  }
1518  else
1519  {
1521  }
1522 
1523  m_orderBookDB.setup(getLedgerMaster().getCurrentLedger());
1524 
1526 
1527  if (!cluster_->load(config().section(SECTION_CLUSTER_NODES)))
1528  {
1529  JLOG(m_journal.fatal()) << "Invalid entry in cluster configuration.";
1530  return false;
1531  }
1532 
1533  {
1535  return false;
1536 
1537  if (!validatorManifests_->load(
1538  getWalletDB(),
1539  "ValidatorManifests",
1541  config().section(SECTION_VALIDATOR_KEY_REVOCATION).values()))
1542  {
1543  JLOG(m_journal.fatal()) << "Invalid configured validator manifest.";
1544  return false;
1545  }
1546 
1547  publisherManifests_->load(getWalletDB(), "PublisherManifests");
1548 
1549  // Setup trusted validators
1550  if (!validators_->load(
1552  config().section(SECTION_VALIDATORS).values(),
1553  config().section(SECTION_VALIDATOR_LIST_KEYS).values()))
1554  {
1555  JLOG(m_journal.fatal())
1556  << "Invalid entry in validator configuration.";
1557  return false;
1558  }
1559  }
1560 
1561  if (!validatorSites_->load(
1562  config().section(SECTION_VALIDATOR_LIST_SITES).values()))
1563  {
1564  JLOG(m_journal.fatal())
1565  << "Invalid entry in [" << SECTION_VALIDATOR_LIST_SITES << "]";
1566  return false;
1567  }
1568 
1569  //----------------------------------------------------------------------
1570  //
1571  // Server
1572  //
1573  //----------------------------------------------------------------------
1574 
1575  // VFALCO NOTE Unfortunately, in stand-alone mode some code still
1576  // foolishly calls overlay(). When this is fixed we can
1577  // move the instantiation inside a conditional:
1578  //
1579  // if (!config_.standalone())
1581  *this,
1583  *m_jobQueue,
1584  *serverHandler_,
1586  *m_resolver,
1587  get_io_service(),
1588  *config_,
1589  m_collectorManager->collector());
1590  add(*overlay_); // add to PropertyStream
1591 
1592  if (!config_->standalone())
1593  {
1594  // validation and node import require the sqlite db
1595  if (config_->nodeToShard && !nodeToShards())
1596  return false;
1597 
1598  if (config_->validateShards && !validateShards())
1599  return false;
1600  }
1601 
1602  validatorSites_->start();
1603 
1604  // start first consensus round
1605  if (!m_networkOPs->beginConsensus(
1606  m_ledgerMaster->getClosedLedger()->info().hash))
1607  {
1608  JLOG(m_journal.fatal()) << "Unable to start consensus";
1609  return false;
1610  }
1611 
1612  {
1613  try
1614  {
1615  auto setup = setup_ServerHandler(
1617  setup.makeContexts();
1618  serverHandler_->setup(setup, m_journal);
1619  }
1620  catch (std::exception const& e)
1621  {
1622  if (auto stream = m_journal.fatal())
1623  {
1624  stream << "Unable to setup server handler";
1625  if (std::strlen(e.what()) > 0)
1626  stream << ": " << e.what();
1627  }
1628  return false;
1629  }
1630  }
1631 
1632  // Begin connecting to network.
1633  if (!config_->standalone())
1634  {
1635  // Should this message be here, conceptually? In theory this sort
1636  // of message, if displayed, should be displayed from PeerFinder.
1637  if (config_->PEER_PRIVATE && config_->IPS_FIXED.empty())
1638  {
1639  JLOG(m_journal.warn())
1640  << "No outbound peer connections will be made";
1641  }
1642 
1643  // VFALCO NOTE the state timer resets the deadlock detector.
1644  //
1645  m_networkOPs->setStateTimer();
1646  }
1647  else
1648  {
1649  JLOG(m_journal.warn()) << "Running in standalone mode";
1650 
1651  m_networkOPs->setStandAlone();
1652  }
1653 
1654  if (config_->canSign())
1655  {
1656  JLOG(m_journal.warn()) << "*** The server is configured to allow the "
1657  "'sign' and 'sign_for'";
1658  JLOG(m_journal.warn()) << "*** commands. These commands have security "
1659  "implications and have";
1660  JLOG(m_journal.warn()) << "*** been deprecated. They will be removed "
1661  "in a future release of";
1662  JLOG(m_journal.warn()) << "*** rippled.";
1663  JLOG(m_journal.warn()) << "*** If you do not use them to sign "
1664  "transactions please edit your";
1665  JLOG(m_journal.warn())
1666  << "*** configuration file and remove the [enable_signing] stanza.";
1667  JLOG(m_journal.warn()) << "*** If you do use them to sign transactions "
1668  "please migrate to a";
1669  JLOG(m_journal.warn())
1670  << "*** standalone signing solution as soon as possible.";
1671  }
1672 
1673  //
1674  // Execute start up rpc commands.
1675  //
1676  for (auto cmd : config_->section(SECTION_RPC_STARTUP).lines())
1677  {
1678  Json::Reader jrReader;
1679  Json::Value jvCommand;
1680 
1681  if (!jrReader.parse(cmd, jvCommand))
1682  {
1683  JLOG(m_journal.fatal()) << "Couldn't parse entry in ["
1684  << SECTION_RPC_STARTUP << "]: '" << cmd;
1685  }
1686 
1687  if (!config_->quiet())
1688  {
1689  JLOG(m_journal.fatal())
1690  << "Startup RPC: " << jvCommand << std::endl;
1691  }
1692 
1695  RPC::JsonContext context{
1696  {journal("RPCHandler"),
1697  *this,
1698  loadType,
1699  getOPs(),
1700  getLedgerMaster(),
1701  c,
1702  Role::ADMIN},
1703  jvCommand,
1705 
1706  Json::Value jvResult;
1707  RPC::doCommand(context, jvResult);
1708 
1709  if (!config_->quiet())
1710  {
1711  JLOG(m_journal.fatal()) << "Result: " << jvResult << std::endl;
1712  }
1713  }
1714 
1715  if (shardStore_)
1716  {
1717  using namespace boost::filesystem;
1718 
1719  auto stateDb(
1721  stateDBName);
1722 
1723  try
1724  {
1725  if (exists(stateDb) && is_regular_file(stateDb) &&
1727  {
1729  *this, *m_jobQueue);
1730 
1731  assert(handler);
1732 
1733  if (!handler->initFromDB())
1734  {
1735  JLOG(m_journal.fatal())
1736  << "Failed to initialize ShardArchiveHandler.";
1737 
1738  return false;
1739  }
1740 
1741  if (!handler->start())
1742  {
1743  JLOG(m_journal.fatal())
1744  << "Failed to start ShardArchiveHandler.";
1745 
1746  return false;
1747  }
1748  }
1749  }
1750  catch (std::exception const& e)
1751  {
1752  JLOG(m_journal.fatal())
1753  << "Exception when starting ShardArchiveHandler from "
1754  "state database: "
1755  << e.what();
1756 
1757  return false;
1758  }
1759  }
1760 
1761  return true;
1762 }
1763 
1764 void
1765 ApplicationImp::doStart(bool withTimers)
1766 {
1767  startTimers_ = withTimers;
1768  prepare();
1769  start();
1770 }
1771 
1772 void
1774 {
1775  if (!config_->standalone())
1776  {
1777  // VFALCO NOTE This seems unnecessary. If we properly refactor the load
1778  // manager then the deadlock detector can just always be
1779  // "armed"
1780  //
1782  }
1783 
1784  {
1786  cv_.wait(lk, [this] { return isTimeToStop; });
1787  }
1788 
1789  // Stop the server. When this returns, all
1790  // Stoppable objects should be stopped.
1791  JLOG(m_journal.info()) << "Received shutdown request";
1792  stop(m_journal);
1793  JLOG(m_journal.info()) << "Done.";
1794 }
1795 
1796 void
1798 {
1799  // Unblock the main thread (which is sitting in run()).
1800  // When we get C++20 this can use std::latch.
1801  std::lock_guard lk{mut_};
1802 
1803  if (!isTimeToStop)
1804  {
1805  isTimeToStop = true;
1806  cv_.notify_all();
1807  }
1808 }
1809 
1810 bool
1812 {
1813  // from Stoppable mixin
1814  return isStopped();
1815 }
1816 
1817 bool
1819 {
1820  return checkSigs_;
1821 }
1822 
1823 void
1825 {
1826  checkSigs_ = check;
1827 }
1828 
1829 int
1831 {
1832  // Standard handles, config file, misc I/O etc:
1833  int needed = 128;
1834 
1835  // 1.5 times the configured peer limit for peer connections:
1836  needed += static_cast<int>(0.5 + (1.5 * overlay_->limit()));
1837 
1838  // the number of fds needed by the backend (internally
1839  // doubled if online delete is enabled).
1840  needed += std::max(5, m_shaMapStore->fdRequired());
1841 
1842  if (shardStore_)
1843  needed += shardStore_->fdRequired();
1844 
1845  // One fd per incoming connection a port can accept, or
1846  // if no limit is set, assume it'll handle 256 clients.
1847  for (auto const& p : serverHandler_->setup().ports)
1848  needed += std::max(256, p.limit);
1849 
1850  // The minimum number of file descriptors we need is 1024:
1851  return std::max(1024, needed);
1852 }
1853 
1854 //------------------------------------------------------------------------------
1855 
1856 void
1858 {
1859  std::vector<uint256> initialAmendments =
1860  (config_->START_UP == Config::FRESH) ? m_amendmentTable->getDesired()
1862 
1863  std::shared_ptr<Ledger> const genesis = std::make_shared<Ledger>(
1864  create_genesis, *config_, initialAmendments, family());
1865  m_ledgerMaster->storeLedger(genesis);
1866 
1867  auto const next =
1868  std::make_shared<Ledger>(*genesis, timeKeeper().closeTime());
1869  next->updateSkipList();
1870  next->setImmutable(*config_);
1871  openLedger_.emplace(next, cachedSLEs_, logs_->journal("OpenLedger"));
1872  m_ledgerMaster->storeLedger(next);
1873  m_ledgerMaster->switchLCL(next);
1874 }
1875 
1878 {
1879  auto j = journal("Ledger");
1880 
1881  try
1882  {
1883  auto const [ledger, seq, hash] =
1884  loadLedgerHelper("order by LedgerSeq desc limit 1", *this);
1885 
1886  if (!ledger)
1887  return ledger;
1888 
1889  ledger->setImmutable(*config_);
1890 
1891  if (getLedgerMaster().haveLedger(seq))
1892  ledger->setValidated();
1893 
1894  if (ledger->info().hash == hash)
1895  {
1896  JLOG(j.trace()) << "Loaded ledger: " << hash;
1897  return ledger;
1898  }
1899 
1900  if (auto stream = j.error())
1901  {
1902  stream << "Failed on ledger";
1903  Json::Value p;
1904  addJson(p, {*ledger, LedgerFill::full});
1905  stream << p;
1906  }
1907 
1908  return {};
1909  }
1910  catch (SHAMapMissingNode const& mn)
1911  {
1912  JLOG(j.warn()) << "Ledger in database: " << mn.what();
1913  return {};
1914  }
1915 }
1916 
1919 {
1920  try
1921  {
1922  std::ifstream ledgerFile(name, std::ios::in);
1923 
1924  if (!ledgerFile)
1925  {
1926  JLOG(m_journal.fatal()) << "Unable to open file '" << name << "'";
1927  return nullptr;
1928  }
1929 
1930  Json::Reader reader;
1931  Json::Value jLedger;
1932 
1933  if (!reader.parse(ledgerFile, jLedger))
1934  {
1935  JLOG(m_journal.fatal()) << "Unable to parse ledger JSON";
1936  return nullptr;
1937  }
1938 
1939  std::reference_wrapper<Json::Value> ledger(jLedger);
1940 
1941  // accept a wrapped ledger
1942  if (ledger.get().isMember("result"))
1943  ledger = ledger.get()["result"];
1944 
1945  if (ledger.get().isMember("ledger"))
1946  ledger = ledger.get()["ledger"];
1947 
1948  std::uint32_t seq = 1;
1949  auto closeTime = timeKeeper().closeTime();
1950  using namespace std::chrono_literals;
1951  auto closeTimeResolution = 30s;
1952  bool closeTimeEstimated = false;
1953  std::uint64_t totalDrops = 0;
1954 
1955  if (ledger.get().isMember("accountState"))
1956  {
1957  if (ledger.get().isMember(jss::ledger_index))
1958  {
1959  seq = ledger.get()[jss::ledger_index].asUInt();
1960  }
1961 
1962  if (ledger.get().isMember("close_time"))
1963  {
1964  using tp = NetClock::time_point;
1965  using d = tp::duration;
1966  closeTime = tp{d{ledger.get()["close_time"].asUInt()}};
1967  }
1968  if (ledger.get().isMember("close_time_resolution"))
1969  {
1970  using namespace std::chrono;
1971  closeTimeResolution =
1972  seconds{ledger.get()["close_time_resolution"].asUInt()};
1973  }
1974  if (ledger.get().isMember("close_time_estimated"))
1975  {
1976  closeTimeEstimated =
1977  ledger.get()["close_time_estimated"].asBool();
1978  }
1979  if (ledger.get().isMember("total_coins"))
1980  {
1981  totalDrops = beast::lexicalCastThrow<std::uint64_t>(
1982  ledger.get()["total_coins"].asString());
1983  }
1984 
1985  ledger = ledger.get()["accountState"];
1986  }
1987 
1988  if (!ledger.get().isArrayOrNull())
1989  {
1990  JLOG(m_journal.fatal()) << "State nodes must be an array";
1991  return nullptr;
1992  }
1993 
1994  auto loadLedger =
1995  std::make_shared<Ledger>(seq, closeTime, *config_, family());
1996  loadLedger->setTotalDrops(totalDrops);
1997 
1998  for (Json::UInt index = 0; index < ledger.get().size(); ++index)
1999  {
2000  Json::Value& entry = ledger.get()[index];
2001 
2002  if (!entry.isObjectOrNull())
2003  {
2004  JLOG(m_journal.fatal()) << "Invalid entry in ledger";
2005  return nullptr;
2006  }
2007 
2008  uint256 uIndex;
2009 
2010  if (!uIndex.SetHex(entry[jss::index].asString()))
2011  {
2012  JLOG(m_journal.fatal()) << "Invalid entry in ledger";
2013  return nullptr;
2014  }
2015 
2016  entry.removeMember(jss::index);
2017 
2018  STParsedJSONObject stp("sle", ledger.get()[index]);
2019 
2020  if (!stp.object || uIndex.isZero())
2021  {
2022  JLOG(m_journal.fatal()) << "Invalid entry in ledger";
2023  return nullptr;
2024  }
2025 
2026  // VFALCO TODO This is the only place that
2027  // constructor is used, try to remove it
2028  STLedgerEntry sle(*stp.object, uIndex);
2029 
2030  if (!loadLedger->addSLE(sle))
2031  {
2032  JLOG(m_journal.fatal())
2033  << "Couldn't add serialized ledger: " << uIndex;
2034  return nullptr;
2035  }
2036  }
2037 
2038  loadLedger->stateMap().flushDirty(
2039  hotACCOUNT_NODE, loadLedger->info().seq);
2040 
2041  loadLedger->setAccepted(
2042  closeTime, closeTimeResolution, !closeTimeEstimated, *config_);
2043 
2044  return loadLedger;
2045  }
2046  catch (std::exception const& x)
2047  {
2048  JLOG(m_journal.fatal()) << "Ledger contains invalid data: " << x.what();
2049  return nullptr;
2050  }
2051 }
2052 
2053 bool
2055  std::string const& ledgerID,
2056  bool replay,
2057  bool isFileName)
2058 {
2059  try
2060  {
2061  std::shared_ptr<Ledger const> loadLedger, replayLedger;
2062 
2063  if (isFileName)
2064  {
2065  if (!ledgerID.empty())
2066  loadLedger = loadLedgerFromFile(ledgerID);
2067  }
2068  else if (ledgerID.length() == 64)
2069  {
2070  uint256 hash;
2071 
2072  if (hash.SetHex(ledgerID))
2073  {
2074  loadLedger = loadByHash(hash, *this);
2075 
2076  if (!loadLedger)
2077  {
2078  // Try to build the ledger from the back end
2079  auto il = std::make_shared<InboundLedger>(
2080  *this,
2081  hash,
2082  0,
2084  stopwatch());
2085  if (il->checkLocal())
2086  loadLedger = il->getLedger();
2087  }
2088  }
2089  }
2090  else if (ledgerID.empty() || boost::iequals(ledgerID, "latest"))
2091  {
2092  loadLedger = getLastFullLedger();
2093  }
2094  else
2095  {
2096  // assume by sequence
2097  std::uint32_t index;
2098 
2099  if (beast::lexicalCastChecked(index, ledgerID))
2100  loadLedger = loadByIndex(index, *this);
2101  }
2102 
2103  if (!loadLedger)
2104  return false;
2105 
2106  if (replay)
2107  {
2108  // Replay a ledger close with same prior ledger and transactions
2109 
2110  // this ledger holds the transactions we want to replay
2111  replayLedger = loadLedger;
2112 
2113  JLOG(m_journal.info()) << "Loading parent ledger";
2114 
2115  loadLedger = loadByHash(replayLedger->info().parentHash, *this);
2116  if (!loadLedger)
2117  {
2118  JLOG(m_journal.info())
2119  << "Loading parent ledger from node store";
2120 
2121  // Try to build the ledger from the back end
2122  auto il = std::make_shared<InboundLedger>(
2123  *this,
2124  replayLedger->info().parentHash,
2125  0,
2127  stopwatch());
2128 
2129  if (il->checkLocal())
2130  loadLedger = il->getLedger();
2131 
2132  if (!loadLedger)
2133  {
2134  JLOG(m_journal.fatal()) << "Replay ledger missing/damaged";
2135  assert(false);
2136  return false;
2137  }
2138  }
2139  }
2140  using namespace std::chrono_literals;
2141  using namespace date;
2142  static constexpr NetClock::time_point ledgerWarnTimePoint{
2143  sys_days{January / 1 / 2018} - sys_days{January / 1 / 2000}};
2144  if (loadLedger->info().closeTime < ledgerWarnTimePoint)
2145  {
2146  JLOG(m_journal.fatal())
2147  << "\n\n*** WARNING ***\n"
2148  "You are replaying a ledger from before "
2149  << to_string(ledgerWarnTimePoint)
2150  << " UTC.\n"
2151  "This replay will not handle your ledger as it was "
2152  "originally "
2153  "handled.\nConsider running an earlier version of rippled "
2154  "to "
2155  "get the older rules.\n*** CONTINUING ***\n";
2156  }
2157 
2158  JLOG(m_journal.info()) << "Loading ledger " << loadLedger->info().hash
2159  << " seq:" << loadLedger->info().seq;
2160 
2161  if (loadLedger->info().accountHash.isZero())
2162  {
2163  JLOG(m_journal.fatal()) << "Ledger is empty.";
2164  assert(false);
2165  return false;
2166  }
2167 
2168  if (!loadLedger->walkLedger(journal("Ledger")))
2169  {
2170  JLOG(m_journal.fatal()) << "Ledger is missing nodes.";
2171  assert(false);
2172  return false;
2173  }
2174 
2175  if (!loadLedger->assertSane(journal("Ledger")))
2176  {
2177  JLOG(m_journal.fatal()) << "Ledger is not sane.";
2178  assert(false);
2179  return false;
2180  }
2181 
2182  m_ledgerMaster->setLedgerRangePresent(
2183  loadLedger->info().seq, loadLedger->info().seq);
2184 
2185  m_ledgerMaster->switchLCL(loadLedger);
2186  loadLedger->setValidated();
2187  m_ledgerMaster->setFullLedger(loadLedger, true, false);
2188  openLedger_.emplace(
2189  loadLedger, cachedSLEs_, logs_->journal("OpenLedger"));
2190 
2191  if (replay)
2192  {
2193  // inject transaction(s) from the replayLedger into our open ledger
2194  // and build replay structure
2195  auto replayData =
2196  std::make_unique<LedgerReplay>(loadLedger, replayLedger);
2197 
2198  for (auto const& [_, tx] : replayData->orderedTxns())
2199  {
2200  (void)_;
2201  auto txID = tx->getTransactionID();
2202 
2203  auto s = std::make_shared<Serializer>();
2204  tx->add(*s);
2205 
2207 
2208  openLedger_->modify(
2209  [&txID, &s](OpenView& view, beast::Journal j) {
2210  view.rawTxInsert(txID, std::move(s), nullptr);
2211  return true;
2212  });
2213  }
2214 
2215  m_ledgerMaster->takeReplay(std::move(replayData));
2216  }
2217  }
2218  catch (SHAMapMissingNode const& mn)
2219  {
2220  JLOG(m_journal.fatal())
2221  << "While loading specified ledger: " << mn.what();
2222  return false;
2223  }
2224  catch (boost::bad_lexical_cast&)
2225  {
2226  JLOG(m_journal.fatal())
2227  << "Ledger specified '" << ledgerID << "' is not valid";
2228  return false;
2229  }
2230 
2231  return true;
2232 }
2233 
2234 bool
2236 {
2237  if (!config().ELB_SUPPORT)
2238  return true;
2239 
2240  if (isShutdown())
2241  {
2242  reason = "Server is shutting down";
2243  return false;
2244  }
2245 
2246  if (getOPs().isNeedNetworkLedger())
2247  {
2248  reason = "Not synchronized with network yet";
2249  return false;
2250  }
2251 
2252  if (getOPs().getOperatingMode() < OperatingMode::SYNCING)
2253  {
2254  reason = "Not synchronized with network";
2255  return false;
2256  }
2257 
2258  if (!getLedgerMaster().isCaughtUp(reason))
2259  return false;
2260 
2261  if (getFeeTrack().isLoadedLocal())
2262  {
2263  reason = "Too much load";
2264  return false;
2265  }
2266 
2267  if (getOPs().isAmendmentBlocked())
2268  {
2269  reason = "Server version too old";
2270  return false;
2271  }
2272 
2273  return true;
2274 }
2275 
2278 {
2279  return logs_->journal(name);
2280 }
2281 
2282 bool
2284 {
2285  assert(overlay_);
2286  assert(!config_->standalone());
2287 
2288  if (config_->section(ConfigSection::shardDatabase()).empty())
2289  {
2290  JLOG(m_journal.fatal())
2291  << "The [shard_db] configuration setting must be set";
2292  return false;
2293  }
2294  if (!shardStore_)
2295  {
2296  JLOG(m_journal.fatal()) << "Invalid [shard_db] configuration";
2297  return false;
2298  }
2299  shardStore_->import(getNodeStore());
2300  return true;
2301 }
2302 
2303 bool
2305 {
2306  assert(overlay_);
2307  assert(!config_->standalone());
2308 
2309  if (config_->section(ConfigSection::shardDatabase()).empty())
2310  {
2311  JLOG(m_journal.fatal())
2312  << "The [shard_db] configuration setting must be set";
2313  return false;
2314  }
2315  if (!shardStore_)
2316  {
2317  JLOG(m_journal.fatal()) << "Invalid [shard_db] configuration";
2318  return false;
2319  }
2320  shardStore_->validate();
2321  return true;
2322 }
2323 
2324 void
2326 {
2327  boost::optional<LedgerIndex> seq;
2328  {
2329  auto db = getLedgerDB().checkoutDb();
2330  *db << "SELECT MAX(LedgerSeq) FROM Ledgers;", soci::into(seq);
2331  }
2332  if (seq)
2333  maxDisallowedLedger_ = *seq;
2334 
2335  JLOG(m_journal.trace())
2336  << "Max persisted ledger is " << maxDisallowedLedger_;
2337 }
2338 
2339 //------------------------------------------------------------------------------
2340 
2341 Application::Application() : beast::PropertyStream::Source("app")
2342 {
2343 }
2344 
2345 //------------------------------------------------------------------------------
2346 
2349  std::unique_ptr<Config> config,
2350  std::unique_ptr<Logs> logs,
2351  std::unique_ptr<TimeKeeper> timeKeeper)
2352 {
2353  return std::make_unique<ApplicationImp>(
2354  std::move(config), std::move(logs), std::move(timeKeeper));
2355 }
2356 
2357 } // namespace ripple
ripple::NodeStoreScheduler
A NodeStore::Scheduler which uses the JobQueue and implements the Stoppable API.
Definition: NodeStoreScheduler.h:32
ripple::Validations::expire
void expire()
Expire old validation sets.
Definition: Validations.h:695
ripple::detail::AppFamily::AppFamily
AppFamily(AppFamily const &)=delete
beast::PropertyStream::Source::name
std::string const & name() const
Returns the name of this source.
Definition: beast_PropertyStream.cpp:190
ripple::ApplicationImp::m_resourceManager
std::unique_ptr< Resource::Manager > m_resourceManager
Definition: Application.cpp:344
ripple::ValidatorKeys::publicKey
PublicKey publicKey
Definition: ValidatorKeys.h:39
beast::Journal::fatal
Stream fatal() const
Definition: Journal.h:339
ripple::setup_TxQ
TxQ::Setup setup_TxQ(Config const &config)
Build a TxQ::Setup object from application configuration.
Definition: TxQ.cpp:1481
ripple::ApplicationImp::getTxnDB
DatabaseCon & getTxnDB() override
Definition: Application.cpp:930
ripple::NodeStore::DummyScheduler
Simple NodeStore Scheduler that just peforms the tasks synchronously.
Definition: DummyScheduler.h:29
ripple::ApplicationImp::mTxnDB
std::unique_ptr< DatabaseCon > mTxnDB
Definition: Application.cpp:378
ripple::ApplicationImp::getValidationPublicKey
PublicKey const & getValidationPublicKey() const override
Definition: Application.cpp:705
ripple::ApplicationImp::m_tempNodeCache
NodeCache m_tempNodeCache
Definition: Application.cpp:338
ripple::Section
Holds a collection of configuration values.
Definition: BasicConfig.h:43
ripple::NetworkOPs
Provides server functionality for clients.
Definition: NetworkOPs.h:88
ripple::ApplicationImp::shardStore_
std::unique_ptr< NodeStore::DatabaseShard > shardStore_
Definition: Application.cpp:350
ripple::loadLedgerHelper
std::tuple< std::shared_ptr< Ledger >, std::uint32_t, uint256 > loadLedgerHelper(std::string const &sqlSuffix, Application &app, bool acquire)
Definition: Ledger.cpp:1010
ripple::Application
Definition: Application.h:94
ripple::RPC::ShardArchiveHandler::getDownloadDirectory
static boost::filesystem::path getDownloadDirectory(Config const &config)
Definition: ShardArchiveHandler.cpp:41
ripple::WalletDBName
constexpr auto WalletDBName
Definition: DBInit.h:138
ripple::detail::AppFamily::missing_node
void missing_node(uint256 const &hash, std::uint32_t seq) override
Definition: Application.cpp:230
ripple::detail::AppFamily::treecache
TreeNodeCache & treecache() override
Definition: Application.cpp:165
ripple::RPC::JsonContext
Definition: Context.h:52
ripple::ApplicationImp::getLedgerDB
DatabaseCon & getLedgerDB() override
Definition: Application.cpp:936
ripple::LoadManager::activateDeadlockDetector
void activateDeadlockDetector()
Turn on deadlock detection.
Definition: LoadManager.cpp:63
ripple::ApplicationImp::m_inboundTransactions
std::unique_ptr< InboundTransactions > m_inboundTransactions
Definition: Application.cpp:357
ripple::ApplicationImp::websocketServers_
std::vector< std::unique_ptr< Stoppable > > websocketServers_
Definition: Application.cpp:382
ripple::LoadManager
Manages load sources.
Definition: LoadManager.h:43
ripple::ApplicationImp::validators
ValidatorList & validators() override
Definition: Application.cpp:850
std::strlen
T strlen(T... args)
ripple::STLedgerEntry
Definition: STLedgerEntry.h:30
ripple::NodeStore::Database
Persistency layer for NodeObject.
Definition: Database.h:53
std::string
STL class.
ripple::detail::AppFamily::reset
void reset() override
Definition: Application.cpp:236
ripple::ApplicationImp::cachedSLEs
CachedSLEs & cachedSLEs() override
Definition: Application.cpp:820
std::shared_ptr
STL class.
ripple::ApplicationImp::getNodeStore
NodeStore::Database & getNodeStore() override
Definition: Application.cpp:778
ripple::loadNodeIdentity
std::pair< PublicKey, SecretKey > loadNodeIdentity(Application &app)
The cryptographic credentials identifying this server instance.
Definition: NodeIdentity.cpp:32
ripple::TaggedCache< uint256, SHAMapAbstractNode >
ripple::ApplicationImp::serverOkay
bool serverOkay(std::string &reason) override
Definition: Application.cpp:2235
ripple::loadByIndex
std::shared_ptr< Ledger > loadByIndex(std::uint32_t ledgerIndex, Application &app, bool acquire)
Definition: Ledger.cpp:1102
ripple::detail::AppFamily::shardBacked_
const bool shardBacked_
Definition: Application.cpp:94
ripple::LedgerMaster::sweep
void sweep()
Definition: LedgerMaster.cpp:1699
ripple::ApplicationImp::mValidations
RCLValidations mValidations
Definition: Application.cpp:370
ripple::TransactionMaster::sweep
void sweep(void)
Definition: TransactionMaster.cpp:145
std::exception
STL class.
ripple::ApplicationImp::getAcceptedLedgerCache
TaggedCache< uint256, AcceptedLedger > & getAcceptedLedgerCache() override
Definition: Application.cpp:747
ripple::base_uint::isNonZero
bool isNonZero() const
Definition: base_uint.h:480
ripple::Stoppable::stopped
void stopped()
Called by derived classes to indicate that the stoppable has stopped.
Definition: Stoppable.cpp:72
ripple::DatabaseCon::Setup
Definition: DatabaseCon.h:85
cstring
ripple::ApplicationImp::getHashRouter
HashRouter & getHashRouter() override
Definition: Application.cpp:838
beast::Journal::trace
Stream trace() const
Severity stream access functions.
Definition: Journal.h:309
beast::PropertyStream::Map
Definition: PropertyStream.h:236
ripple::ApplicationImp::shardFamily_
std::unique_ptr< detail::AppFamily > shardFamily_
Definition: Application.cpp:351
ripple::ApplicationImp::validatorSites_
std::unique_ptr< ValidatorSite > validatorSites_
Definition: Application.cpp:365
ripple::ApplicationImp::mWalletDB
std::unique_ptr< DatabaseCon > mWalletDB
Definition: Application.cpp:380
ripple::SizedItem::nodeCacheSize
@ nodeCacheSize
ripple::ApplicationImp::getPathRequests
PathRequests & getPathRequests() override
Definition: Application.cpp:814
ripple::TaggedCache::sweep
void sweep()
Definition: TaggedCache.h:169
ripple::ApplicationImp::m_orderBookDB
OrderBookDB m_orderBookDB
Definition: Application.cpp:353
ripple::TransactionMaster
Definition: TransactionMaster.h:36
ripple::ValidatorSite
Definition: ValidatorSite.h:67
std::pair
std::vector::reserve
T reserve(T... args)
ripple::ApplicationImp::onStop
void onStop() override
Override called when the stop notification is issued.
Definition: Application.cpp:1110
ripple::detail::BasicFullBelowCache< uint256 >
ripple::ApplicationImp::onWrite
void onWrite(beast::PropertyStream::Map &stream) override
Subclass override.
Definition: Application.cpp:1182
ripple::LedgerMaster
Definition: LedgerMaster.h:54
ripple::ApplicationImp::getInboundLedgers
InboundLedgers & getInboundLedgers() override
Definition: Application.cpp:735
ripple::ApplicationImp::accountIDCache
AccountIDCache const & accountIDCache() const override
Definition: Application.cpp:898
ripple::OpenView
Writable ledger view that accumulates state and tx changes.
Definition: OpenView.h:52
ripple::ApplicationImp::io_latency_sampler::cancel_async
void cancel_async()
Definition: Application.cpp:313
Json::UInt
unsigned int UInt
Definition: json_forwards.h:27
ripple::detail::AppFamily::missing_node
void missing_node(std::uint32_t seq) override
Definition: Application.cpp:195
ripple::hotACCOUNT_NODE
@ hotACCOUNT_NODE
Definition: NodeObject.h:35
ripple::RPC::ShardArchiveHandler::recoverInstance
static pointer recoverInstance(Application &app, Stoppable &parent)
Definition: ShardArchiveHandler.cpp:71
ripple::InboundLedger::Reason::GENERIC
@ GENERIC
std::vector
STL class.
ripple::ConfigSection::shardDatabase
static std::string shardDatabase()
Definition: ConfigSections.h:38
ripple::make_AmendmentTable
std::unique_ptr< AmendmentTable > make_AmendmentTable(std::chrono::seconds majorityTime, int majorityFraction, Section const &supported, Section const &enabled, Section const &vetoed, beast::Journal journal)
Definition: AmendmentTable.cpp:654
std::string::length
T length(T... args)
ripple::ValidatorList::trustedPublisher
bool trustedPublisher(PublicKey const &identity) const
Returns true if public key is a trusted publisher.
Definition: ValidatorList.cpp:591
ripple::ApplicationImp::waitHandlerCounter_
ClosureCounter< void, boost::system::error_code const & > waitHandlerCounter_
Definition: Application.cpp:373
ripple::ApplicationImp::getOPs
NetworkOPs & getOPs() override
Definition: Application.cpp:711
ripple::ApplicationImp::run
void run() override
Definition: Application.cpp:1773
ripple::make_Overlay
std::unique_ptr< Overlay > make_Overlay(Application &app, Overlay::Setup const &setup, Stoppable &parent, ServerHandler &serverHandler, Resource::Manager &resourceManager, Resolver &resolver, boost::asio::io_service &io_service, BasicConfig const &config, beast::insight::Collector::ptr const &collector)
Creates the implementation of Overlay.
Definition: OverlayImpl.cpp:1360
ripple::CollectorManager
Provides the beast::insight::Collector service.
Definition: CollectorManager.h:29
ripple::ConfigSection::importNodeDatabase
static std::string importNodeDatabase()
Definition: ConfigSections.h:43
std::chrono::milliseconds
ripple::Config::NODE_SIZE
std::size_t NODE_SIZE
Definition: Config.h:164
ripple::ApplicationImp::m_acceptedLedgerCache
TaggedCache< uint256, AcceptedLedger > m_acceptedLedgerCache
Definition: Application.cpp:358
ripple::ApplicationImp::setup
bool setup() override
Definition: Application.cpp:1373
ripple::SHAMapStore
class to create database, launch online delete thread, and related SQLite database
Definition: SHAMapStore.h:36
ripple::make_LoadManager
std::unique_ptr< LoadManager > make_LoadManager(Application &app, Stoppable &parent, beast::Journal journal)
Definition: LoadManager.cpp:221
ripple::ApplicationImp::validatorManifests
ManifestCache & validatorManifests() override
Definition: Application.cpp:862
ripple::ApplicationImp::getWalletDB
DatabaseCon & getWalletDB() override
Retrieve the "wallet database".
Definition: Application.cpp:942
ripple::ApplicationImp::getCollectorManager
CollectorManager & getCollectorManager() override
Definition: Application.cpp:669
ripple::ApplicationImp::sweepTimer_
boost::asio::steady_timer sweepTimer_
Definition: Application.cpp:374
ripple::ApplicationImp::cluster_
std::unique_ptr< Cluster > cluster_
Definition: Application.cpp:360
ripple::ApplicationImp::getShardStore
NodeStore::DatabaseShard * getShardStore() override
Definition: Application.cpp:784
ripple::ApplicationImp::openLedger
OpenLedger const & openLedger() const override
Definition: Application.cpp:910
ripple::ApplicationImp::getIOLatency
std::chrono::milliseconds getIOLatency() override
Definition: Application.cpp:723
ripple::ApplicationImp::openLedger_
boost::optional< OpenLedger > openLedger_
Definition: Application.cpp:335
ripple::ApplicationImp::m_shaMapStore
std::unique_ptr< SHAMapStore > m_shaMapStore
Definition: Application.cpp:332
ripple::SizedItem::treeCacheAge
@ treeCacheAge
ripple::Config::LOAD
@ LOAD
Definition: Config.h:122
beast::Journal::warn
Stream warn() const
Definition: Journal.h:327
std::recursive_mutex
STL class.
std::reference_wrapper::get
T get(T... args)
ripple::ApplicationImp::getIOService
boost::asio::io_service & getIOService() override
Definition: Application.cpp:717
std::lock_guard
STL class.
ripple::kilobytes
constexpr auto kilobytes(T value) noexcept
Definition: ByteUtilities.h:27
beast::severities
A namespace for easy access to logging severity values.
Definition: Journal.h:29
ripple::perf::PerfLog
Singleton class that maintains performance counters and optionally writes Json-formatted data to a di...
Definition: PerfLog.h:46
ripple::STParsedJSONObject
Holds the serialized result of parsing an input JSON object.
Definition: STParsedJSON.h:31
ripple::PendingSaves
Keeps track of which ledgers haven't been fully saved.
Definition: PendingSaves.h:36
ripple::Resource::feeReferenceRPC
const Charge feeReferenceRPC
ripple::Pathfinder::initPathTable
static void initPathTable()
Definition: Pathfinder.cpp:1257
std::cerr
ripple::DatabaseCon::Setup::dataDir
boost::filesystem::path dataDir
Definition: DatabaseCon.h:91
ripple::ApplicationImp::ApplicationImp
ApplicationImp(std::unique_ptr< Config > config, std::unique_ptr< Logs > logs, std::unique_ptr< TimeKeeper > timeKeeper)
Definition: Application.cpp:420
ripple::ApplicationImp::signalStop
void signalStop() override
Definition: Application.cpp:1797
ripple::ApplicationImp::cluster
Cluster & cluster() override
Definition: Application.cpp:874
ripple::stopwatch
Stopwatch & stopwatch()
Returns an instance of a wall clock.
Definition: chrono.h:86
ripple::fullBelowExpiration
constexpr std::chrono::seconds fullBelowExpiration
Definition: app/main/Tuning.h:26
ripple::to_string
std::string to_string(ListDisposition disposition)
Definition: ValidatorList.cpp:41
ripple::detail::BasicFullBelowCache::reset
void reset()
Definition: FullBelowCache.h:134
ripple::ApplicationImp::getLedgerMaster
LedgerMaster & getLedgerMaster() override
Definition: Application.cpp:729
Json::Reader
Unserialize a JSON document into a Value.
Definition: json_reader.h:36
ripple::CollectorManager::New
static std::unique_ptr< CollectorManager > New(Section const &params, beast::Journal journal)
Definition: CollectorManager.cpp:74
ripple::ApplicationImp::family
Family & family() override
Definition: Application.cpp:675
ripple::ResolverAsio::New
static std::unique_ptr< ResolverAsio > New(boost::asio::io_service &, beast::Journal)
Definition: ResolverAsio.cpp:407
iostream
ripple::ApplicationImp::family_
detail::AppFamily family_
Definition: Application.cpp:349
ripple::detail::AppFamily::db_
NodeStore::Database & db_
Definition: Application.cpp:93
ripple::ApplicationImp::m_nodeStore
std::unique_ptr< NodeStore::Database > m_nodeStore
Definition: Application.cpp:348
ripple::LgrDBInit
constexpr std::array< char const *, 5 > LgrDBInit
Definition: DBInit.h:37
ripple::ApplicationImp::perfLog_
std::unique_ptr< perf::PerfLog > perfLog_
Definition: Application.cpp:325
ripple::AccountIDCache
Caches the base58 representations of AccountIDs.
Definition: AccountID.h:147
ripple::ApplicationImp::nodeIdentity_
std::pair< PublicKey, SecretKey > nodeIdentity_
Definition: Application.cpp:341
ripple::InboundLedgers::sweep
virtual void sweep()=0
ripple::ValidatorKeys
Validator keys and manifest as set in configuration file.
Definition: ValidatorKeys.h:36
ripple::ApplicationImp::mLedgerDB
std::unique_ptr< DatabaseCon > mLedgerDB
Definition: Application.cpp:379
ripple::detail::AppFamily::AppFamily
AppFamily(Application &app, NodeStore::Database &db, CollectorManager &collectorManager)
Definition: Application.cpp:123
ripple::make_InboundLedgers
std::unique_ptr< InboundLedgers > make_InboundLedgers(Application &app, InboundLedgers::clock_type &clock, Stoppable &parent, beast::insight::Collector::ptr const &collector)
Definition: InboundLedgers.cpp:437
ripple::detail::AppFamily::fullbelow
FullBelowCache & fullbelow() override
Definition: Application.cpp:153
ripple::HashRouter
Routing table for objects identified by hash.
Definition: HashRouter.h:52
ripple::forceValidity
void forceValidity(HashRouter &router, uint256 const &txid, Validity validity)
Sets the validity of a given transaction in the cache.
Definition: apply.cpp:89
ripple::Application::getInboundLedgers
virtual InboundLedgers & getInboundLedgers()=0
ripple::ApplicationImp::onStart
void onStart() override
Override called during start.
Definition: Application.cpp:1091
ripple::ApplicationImp::validatorKeys_
const ValidatorKeys validatorKeys_
Definition: Application.cpp:342
ripple::ApplicationImp::timeKeeper_
std::unique_ptr< TimeKeeper > timeKeeper_
Definition: Application.cpp:322
ripple::OperatingMode::SYNCING
@ SYNCING
fallen slightly behind
ripple::ApplicationImp::cv_
std::condition_variable cv_
Definition: Application.cpp:386
ripple::SHAMapMissingNode
Definition: SHAMapMissingNode.h:55
ripple::Validity::SigGoodOnly
@ SigGoodOnly
Signature is good, but local checks fail.
ripple::RootStoppable::prepare
void prepare()
Prepare all contained Stoppable objects.
Definition: Stoppable.cpp:181
ripple::detail::AppFamily::operator=
AppFamily & operator=(AppFamily const &)=delete
ripple::ApplicationImp::m_inboundLedgers
std::unique_ptr< InboundLedgers > m_inboundLedgers
Definition: Application.cpp:356
ripple::ApplicationImp::peerReservations_
std::unique_ptr< PeerReservationTable > peerReservations_
Definition: Application.cpp:361
std::vector::push_back
T push_back(T... args)
ripple::setup_ServerHandler
ServerHandler::Setup setup_ServerHandler(Config const &config, std::ostream &&log)
Definition: ServerHandlerImp.cpp:1143
ripple::ApplicationImp::loadLedgerFromFile
std::shared_ptr< Ledger > loadLedgerFromFile(std::string const &ledgerID)
Definition: Application.cpp:1918
ripple::ApplicationImp::checkSigs
bool checkSigs() const override
Definition: Application.cpp:1818
ripple::ApplicationImp::journal
beast::Journal journal(std::string const &name) override
Definition: Application.cpp:2277
ripple::ApplicationImp::startTimers_
bool startTimers_
Definition: Application.cpp:376
ripple::TxDBName
constexpr auto TxDBName
Definition: DBInit.h:62
ripple::base_uint< 256 >
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:3897
ripple::ApplicationImp::entropyTimer_
boost::asio::steady_timer entropyTimer_
Definition: Application.cpp:375
ripple::ApplicationImp::getMaxDisallowedLedger
LedgerIndex getMaxDisallowedLedger() override
Ensure that a newly-started validator does not sign proposals older than the last ledger it persisted...
Definition: Application.cpp:1339
ripple::ApplicationImp::nodeToShards
bool nodeToShards()
Definition: Application.cpp:2283
ripple::ApplicationImp::hashRouter_
std::unique_ptr< HashRouter > hashRouter_
Definition: Application.cpp:369
ripple::ApplicationImp::getMasterMutex
Application::MutexType & getMasterMutex() override
Definition: Application.cpp:790
ripple::detail::AppFamily
Definition: Application.cpp:87
ripple::RootStoppable::stop
void stop(beast::Journal j)
Notify a root stoppable and children to stop, and block until stopped.
Definition: Stoppable.cpp:199
ripple::HashRouter::getDefaultRecoverLimit
static std::uint32_t getDefaultRecoverLimit()
Definition: HashRouter.h:160
ripple::ApplicationImp::m_ledgerMaster
std::unique_ptr< LedgerMaster > m_ledgerMaster
Definition: Application.cpp:355
ripple::Stoppable::isStopped
bool isStopped() const
Returns true if the requested stop has completed.
Definition: Stoppable.cpp:60
ripple::RPC::doCommand
Status doCommand(RPC::JsonContext &context, Json::Value &result)
Execute an RPC command and store the results in a Json::Value.
Definition: RPCHandler.cpp:199
ripple::setup_Overlay
Overlay::Setup setup_Overlay(BasicConfig const &config)
Definition: OverlayImpl.cpp:1255
ripple::ApplicationImp::logs
Logs & logs() override
Definition: Application.cpp:657
ripple::ApplicationImp::getPerfLog
perf::PerfLog & getPerfLog() override
Definition: Application.cpp:766
ripple::ApplicationImp::m_jobQueue
std::unique_ptr< JobQueue > m_jobQueue
Definition: Application.cpp:347
ripple::ApplicationImp::checkSigs_
std::atomic< bool > checkSigs_
Definition: Application.cpp:390
std::reference_wrapper
ripple::setup_DatabaseCon
DatabaseCon::Setup setup_DatabaseCon(Config const &c)
Definition: DatabaseCon.cpp:29
ripple::loadByHash
std::shared_ptr< Ledger > loadByHash(uint256 const &ledgerHash, Application &app, bool acquire)
Definition: Ledger.cpp:1117
ripple::TxQ
Transaction Queue.
Definition: TxQ.h:54
ripple::ApplicationImp::numberOfThreads
static std::size_t numberOfThreads(Config const &config)
Definition: Application.cpp:401
ripple::DatabaseCon::checkoutDb
LockedSociSession checkoutDb()
Definition: DatabaseCon.h:129
ripple::LgrDBPragma
constexpr std::array< char const *, 3 > LgrDBPragma
Definition: DBInit.h:32
ripple::base_uint::isZero
bool isZero() const
Definition: base_uint.h:475
ripple::ApplicationImp::getSHAMapStore
SHAMapStore & getSHAMapStore() override
Definition: Application.cpp:886
ripple::RootStoppable
Definition: Stoppable.h:352
ripple::Role::ADMIN
@ ADMIN
beast::PropertyStream::Source::add
void add(Source &source)
Add a child source.
Definition: beast_PropertyStream.cpp:196
ripple::ApplicationImp::getAmendmentTable
AmendmentTable & getAmendmentTable() override
Definition: Application.cpp:826
ripple::ApplicationImp::loadOldLedger
bool loadOldLedger(std::string const &ledgerID, bool replay, bool isFilename)
Definition: Application.cpp:2054
ripple::ApplicationImp::initSQLiteDBs
bool initSQLiteDBs()
Definition: Application.cpp:957
ripple::Application::getLedgerMaster
virtual LedgerMaster & getLedgerMaster()=0
ripple::PublicKey
A public key.
Definition: PublicKey.h:59
ripple::InboundLedgers::acquire
virtual std::shared_ptr< Ledger const > acquire(uint256 const &hash, std::uint32_t seq, InboundLedger::Reason)=0
std::atomic::load
T load(T... args)
ripple::detail::BasicFullBelowCache::sweep
void sweep()
Remove expired cache items.
Definition: FullBelowCache.h:89
ripple::Config
Definition: Config.h:66
ripple::ApplicationImp::io_latency_sampler::cancel
void cancel()
Definition: Application.cpp:307
ripple::PublicKey::size
std::size_t size() const noexcept
Definition: PublicKey.h:87
ripple::Cluster
Definition: Cluster.h:38
std::thread::hardware_concurrency
T hardware_concurrency(T... args)
ripple::CachedSLEs
Caches SLEs by their digest.
Definition: CachedSLEs.h:32
ripple::ValidatorList
Definition: ValidatorList.h:118
ripple::ApplicationImp::getResourceManager
Resource::Manager & getResourceManager() override
Definition: Application.cpp:802
ripple::ApplicationImp::peerReservations
PeerReservationTable & peerReservations() override
Definition: Application.cpp:880
ripple::ApplicationImp::publisherManifests
ManifestCache & publisherManifests() override
Definition: Application.cpp:868
ripple::ApplicationImp::doStart
void doStart(bool withTimers) override
Definition: Application.cpp:1765
ripple::ApplicationImp::m_amendmentTable
std::unique_ptr< AmendmentTable > m_amendmentTable
Definition: Application.cpp:367
ripple::Config::NETWORK
@ NETWORK
Definition: Config.h:122
ripple::ApplicationImp::overlay
Overlay & overlay() override
Definition: Application.cpp:916
ripple::megabytes
constexpr auto megabytes(T value) noexcept
Definition: ByteUtilities.h:34
ripple::ApplicationImp::pendingSaves
PendingSaves & pendingSaves() override
Definition: Application.cpp:892
ripple::ApplicationImp::m_collectorManager
std::unique_ptr< CollectorManager > m_collectorManager
Definition: Application.cpp:339
ripple::HashRouter::getDefaultHoldTime
static std::chrono::seconds getDefaultHoldTime()
Definition: HashRouter.h:152
ripple::LedgerFill::full
@ full
Definition: LedgerToJson.h:47
std::unique_lock
STL class.
beast::io_latency_probe::sample
void sample(Handler &&handler)
Initiate continuous i/o latency sampling.
Definition: io_latency_probe.h:120
ripple::ApplicationImp::m_txMaster
TransactionMaster m_txMaster
Definition: Application.cpp:329
ripple::TaggedCache::reset
void reset()
Definition: TaggedCache.h:159
ripple::ApplicationImp::validateShards
bool validateShards()
Definition: Application.cpp:2304
ripple::NodeStore::DatabaseShard
A collection of historical shards.
Definition: DatabaseShard.h:37
ripple::LoadFeeTrack
Manages the current fee schedule.
Definition: LoadFeeTrack.h:43
ripple::detail::AppFamily::treecache
TreeNodeCache const & treecache() const override
Definition: Application.cpp:171
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
std::array
STL class.
ripple::CachedSLEs::expire
void expire()
Discard expired entries.
Definition: CachedSLEs.cpp:26
ripple::ApplicationImp::mut_
std::mutex mut_
Definition: Application.cpp:387
ripple::detail::AppFamily::fullbelow_
FullBelowCache fullbelow_
Definition: Application.cpp:92
ripple::ValidatorList::listed
bool listed(PublicKey const &identity) const
Returns true if public key is included on any lists.
Definition: ValidatorList.cpp:551
ripple::RPC::ApiMaximumSupportedVersion
constexpr unsigned int ApiMaximumSupportedVersion
Definition: RPCHelpers.h:214
ripple::ApplicationImp::validatorSites
ValidatorSite & validatorSites() override
Definition: Application.cpp:856
ripple::base_uint::SetHex
bool SetHex(const char *psz, bool bStrict=false)
Parse a hex string into a base_uint The input can be:
Definition: base_uint.h:406
ripple::ApplicationImp::nodeIdentity
std::pair< PublicKey, SecretKey > const & nodeIdentity() override
Definition: Application.cpp:699
beast::Journal::error
Stream error() const
Definition: Journal.h:333
beast::Journal::info
Stream info() const
Definition: Journal.h:321
ripple::ApplicationImp::io_latency_sampler::m_event
beast::insight::Event m_event
Definition: Application.cpp:258
std::chrono::time_point
beast::insight::Event
A metric for reporting event timing.
Definition: Event.h:42
ripple::ApplicationImp::config_
std::unique_ptr< Config > config_
Definition: Application.cpp:320
ripple::BuildInfo::getVersionString
std::string const & getVersionString()
Server version.
Definition: BuildInfo.cpp:61
ripple::OrderBookDB::setup
void setup(std::shared_ptr< ReadView const > const &ledger)
Definition: OrderBookDB.cpp:46
beast::basic_logstream
Definition: Journal.h:428
ripple::detail::AppFamily::j_
const beast::Journal j_
Definition: Application.cpp:95
ripple::ApplicationImp::getLastFullLedger
std::shared_ptr< Ledger > getLastFullLedger()
Definition: Application.cpp:1877
ripple::TimeKeeper::closeTime
virtual time_point closeTime() const =0
Returns the close time, in network time.
ripple::Family
Definition: Family.h:32
ripple::ValidatorKeys::configInvalid
bool configInvalid() const
Definition: ValidatorKeys.h:47
ripple::ClosureCounter
Definition: ClosureCounter.h:40
ripple::SizedItem::lgrDBCache
@ lgrDBCache
ripple::ApplicationImp::isTimeToStop
bool isTimeToStop
Definition: Application.cpp:388
ripple::ApplicationImp::m_io_latency_sampler
io_latency_sampler m_io_latency_sampler
Definition: Application.cpp:394
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
std::uint32_t
std::condition_variable::wait
T wait(T... args)
ripple::ApplicationImp::isShutdown
bool isShutdown() override
Definition: Application.cpp:1811
ripple::ApplicationImp::gotTXSet
void gotTXSet(std::shared_ptr< SHAMap > const &set, bool fromAcquire)
Definition: Application.cpp:753
std::atomic< std::chrono::milliseconds >
ripple::ApplicationImp::startGenesisLedger
void startGenesisLedger()
Definition: Application.cpp:1857
ripple::ApplicationImp::m_signals
boost::asio::signal_set m_signals
Definition: Application.cpp:384
ripple::STParsedJSONObject::object
boost::optional< STObject > object
The STObject if the parse was successful.
Definition: STParsedJSON.h:50
ripple::TimeKeeper
Manages various times used by the server.
Definition: TimeKeeper.h:32
ripple::ClosureCounter::wrap
boost::optional< Wrapper< Closure > > wrap(Closure &&closure)
Wrap the passed closure with a reference counter.
Definition: ClosureCounter.h:178
ripple::SizedItem::txnDBCache
@ txnDBCache
ripple::ApplicationImp::timeKeeper
TimeKeeper & timeKeeper() override
Definition: Application.cpp:687
beast::io_latency_probe< std::chrono::steady_clock >
ripple::OrderBookDB
Definition: OrderBookDB.h:31
ripple::ApplicationImp::io_latency_sampler::operator()
void operator()(Duration const &elapsed)
Definition: Application.cpp:284
ripple::NodeStore::Database::sweep
virtual void sweep()=0
Remove expired entries from the positive and negative caches.
ripple::make_TxQ
std::unique_ptr< TxQ > make_TxQ(TxQ::Setup const &setup, beast::Journal j)
TxQ object factory.
Definition: TxQ.cpp:1553
ripple::InboundLedgers
Manages the lifetime of inbound ledgers.
Definition: InboundLedgers.h:34
ripple::OpenLedger
Represents the open ledger.
Definition: OpenLedger.h:49
ripple::Family::treecache
virtual TreeNodeCache & treecache()=0
ripple::Validations::flush
void flush()
Flush all current validations.
Definition: Validations.h:1022
ripple::fullBelowTargetSize
constexpr std::size_t fullBelowTargetSize
Definition: app/main/Tuning.h:25
ripple::JobQueue
A pool of threads to perform work.
Definition: JobQueue.h:55
ripple::Application::Application
Application()
Definition: Application.cpp:2341
ripple::detail::AppFamily::fullbelow
FullBelowCache const & fullbelow() const override
Definition: Application.cpp:159
ripple::ApplicationImp::setMaxDisallowedLedger
void setMaxDisallowedLedger()
Definition: Application.cpp:2325
ripple::detail::AppFamily::db
NodeStore::Database & db() override
Definition: Application.cpp:177
ripple::Resource::Manager
Tracks load and resource consumption.
Definition: ResourceManager.h:36
ripple::ApplicationImp::shardFamily
Family * shardFamily() override
Definition: Application.cpp:681
ripple::ApplicationImp::io_latency_sampler::lastSample_
std::atomic< std::chrono::milliseconds > lastSample_
Definition: Application.cpp:261
ripple::detail::supportedAmendments
std::vector< std::string > const & supportedAmendments()
Amendments that this server supports, but doesn't enable by default.
Definition: Feature.cpp:81
ripple::ApplicationImp::setSweepTimer
void setSweepTimer()
Definition: Application.cpp:1189
ripple::ApplicationImp::overlay_
std::unique_ptr< Overlay > overlay_
Definition: Application.cpp:381
ripple::BuildInfo::getFullVersionString
std::string const & getFullVersionString()
Full server version string.
Definition: BuildInfo.cpp:74
ripple::stateDBName
static constexpr auto stateDBName
Definition: DBInit.h:173
ripple::ApplicationImp::openLedger
OpenLedger & openLedger() override
Definition: Application.cpp:904
ripple::ApplicationImp::pendingSaves_
PendingSaves pendingSaves_
Definition: Application.cpp:333
ripple::NodeStoreScheduler::setJobQueue
void setJobQueue(JobQueue &jobQueue)
Definition: NodeStoreScheduler.cpp:31
ripple::ApplicationImp::m_resolver
std::unique_ptr< ResolverAsio > m_resolver
Definition: Application.cpp:392
ripple::ApplicationImp::getTxQ
TxQ & getTxQ() override
Definition: Application.cpp:923
ripple::PeerReservationTable
Definition: PeerReservationTable.h:79
ripple::ManifestCache
Remembers manifests with the highest sequence number.
Definition: Manifest.h:209
ripple::TaggedCache::setTargetAge
void setTargetAge(clock_type::duration s)
Definition: TaggedCache.h:120
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::Config::FRESH
@ FRESH
Definition: Config.h:122
ripple::Resource::make_Manager
std::unique_ptr< Manager > make_Manager(beast::insight::Collector::ptr const &collector, beast::Journal journal)
Definition: ResourceManager.cpp:175
ripple::Application::journal
virtual beast::Journal journal(std::string const &name)=0
ripple::ApplicationImp::getTempNodeCache
NodeCache & getTempNodeCache() override
Definition: Application.cpp:772
ripple::ApplicationImp::io_latency_sampler::get
std::chrono::milliseconds get() const
Definition: Application.cpp:301
beast::io_latency_probe::cancel
void cancel()
Cancel all pending i/o.
Definition: io_latency_probe.h:85
Json::Value::removeMember
Value removeMember(const char *key)
Remove and return the named member.
Definition: json_value.cpp:907
ripple::ApplicationImp::grpcServer_
std::unique_ptr< GRPCServer > grpcServer_
Definition: Application.cpp:396
std::endl
T endl(T... args)
ripple::OpenView::rawTxInsert
void rawTxInsert(key_type const &key, std::shared_ptr< Serializer const > const &txn, std::shared_ptr< Serializer const > const &metaData) override
Add a transaction to the tx map.
Definition: OpenView.cpp:238
ripple::ApplicationImp::getJobQueue
JobQueue & getJobQueue() override
Definition: Application.cpp:693
ripple::ApplicationImp::fdRequired
int fdRequired() const override
Definition: Application.cpp:1830
ripple::ApplicationImp::doSweep
void doSweep()
Definition: Application.cpp:1249
ripple::make_SHAMapStore
std::unique_ptr< SHAMapStore > make_SHAMapStore(Application &app, Stoppable &parent, NodeStore::Scheduler &scheduler, beast::Journal journal)
Definition: SHAMapStoreImp.cpp:721
ripple::TaggedCache::setTargetSize
void setTargetSize(int s)
Definition: TaggedCache.h:100
ripple::SizedItem::treeCacheSize
@ treeCacheSize
beast::PropertyStream::Source::Source
Source(std::string const &name)
Definition: beast_PropertyStream.cpp:176
ripple::Overlay
Manages the set of connected peers.
Definition: Overlay.h:52
ripple::ApplicationImp::io_latency_sampler
Definition: Application.cpp:255
ripple::ApplicationImp::getOrderBookDB
OrderBookDB & getOrderBookDB() override
Definition: Application.cpp:808
ripple::ApplicationImp
Definition: Application.cpp:252
ripple::ApplicationImp::getLoadManager
LoadManager & getLoadManager() override
Definition: Application.cpp:796
beast::lexicalCastChecked
bool lexicalCastChecked(Out &out, In in)
Intelligently convert from one type to another.
Definition: LexicalCast.h:266
ripple::detail::AppFamily::journal
beast::Journal const & journal() override
Definition: Application.cpp:147
ripple::ApplicationImp::io_latency_sampler::m_probe
beast::io_latency_probe< std::chrono::steady_clock > m_probe
Definition: Application.cpp:260
ripple::ApplicationImp::accountIDCache_
AccountIDCache accountIDCache_
Definition: Application.cpp:334
std
STL namespace.
ripple::ApplicationImp::m_nodeStoreScheduler
NodeStoreScheduler m_nodeStoreScheduler
Definition: Application.cpp:331
ripple::ApplicationImp::m_loadManager
std::unique_ptr< LoadManager > m_loadManager
Definition: Application.cpp:371
ripple::create_genesis
const create_genesis_t create_genesis
Definition: Ledger.cpp:56
ripple::Config::REPLAY
@ REPLAY
Definition: Config.h:122
ripple::ApplicationImp::getInboundTransactions
InboundTransactions & getInboundTransactions() override
Definition: Application.cpp:741
ripple::detail::AppFamily::maxSeq
LedgerIndex maxSeq
Definition: Application.cpp:98
ripple::detail::AppFamily::maxSeqLock
std::mutex maxSeqLock
Definition: Application.cpp:99
Json::Reader::parse
bool parse(std::string const &document, Value &root)
Read a Value from a JSON document.
Definition: json_reader.cpp:73
condition_variable
ripple::Resource::Consumer
An endpoint that consumes resources.
Definition: Consumer.h:33
ripple::Resource::Charge
A consumption charge.
Definition: Charge.h:30
ripple::detail::AppFamily::acquire
void acquire(uint256 const &hash, std::uint32_t seq)
Definition: Application.cpp:102
ripple::SizedItem::sweepInterval
@ sweepInterval
ripple::DatabaseCon
Definition: DatabaseCon.h:82
ripple::ApplicationImp::mFeeTrack
std::unique_ptr< LoadFeeTrack > mFeeTrack
Definition: Application.cpp:368
ripple::MAJORITY_FRACTION
static const int MAJORITY_FRACTION(204)
ripple::ApplicationImp::getFeeTrack
LoadFeeTrack & getFeeTrack() override
Definition: Application.cpp:832
ripple::addJson
void addJson(Json::Value &json, LedgerFill const &fill)
Given a Ledger and options, fill a Json::Object or Json::Value with a description of the ledger.
Definition: LedgerToJson.cpp:273
ripple::RPC::ShardArchiveHandler::hasInstance
static bool hasInstance()
Definition: ShardArchiveHandler.cpp:83
beast::severities::kDebug
@ kDebug
Definition: Journal.h:35
ripple::ApplicationImp::io_latency_sampler::m_journal
beast::Journal m_journal
Definition: Application.cpp:259
ripple::ApplicationImp::config
Config & config() override
Definition: Application.cpp:663
ripple::ApplicationImp::validators_
std::unique_ptr< ValidatorList > validators_
Definition: Application.cpp:364
std::string::empty
T empty(T... args)
ripple::ApplicationImp::m_journal
beast::Journal m_journal
Definition: Application.cpp:324
ripple::SizedItem::ledgerSize
@ ledgerSize
ripple::Validations< RCLValidationsAdaptor >
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
beast::io_latency_probe::cancel_async
void cancel_async()
Definition: io_latency_probe.h:92
mutex
ripple::ApplicationImp::io_latency_sampler::io_latency_sampler
io_latency_sampler(beast::insight::Event ev, beast::Journal journal, std::chrono::milliseconds interval, boost::asio::io_service &ios)
Definition: Application.cpp:264
beast::Journal::debug
Stream debug() const
Definition: Journal.h:315
ripple::ApplicationImp::serverHandler_
std::unique_ptr< ServerHandler > serverHandler_
Definition: Application.cpp:366
std::size_t
ripple::Family::fullbelow
virtual FullBelowCache & fullbelow()=0
ripple::ApplicationImp::validatorManifests_
std::unique_ptr< ManifestCache > validatorManifests_
Definition: Application.cpp:362
BasicApp
Definition: BasicApp.h:29
ripple::ApplicationImp::m_pathRequests
std::unique_ptr< PathRequests > m_pathRequests
Definition: Application.cpp:354
ripple::ApplicationImp::m_networkOPs
std::unique_ptr< NetworkOPs > m_networkOPs
Definition: Application.cpp:359
ripple::PathRequests
Definition: PathRequests.h:33
ripple::detail::AppFamily::treecache_
TreeNodeCache treecache_
Definition: Application.cpp:91
ripple::ApplicationImp::txQ_
std::unique_ptr< TxQ > txQ_
Definition: Application.cpp:372
ripple::ApplicationImp::cachedSLEs_
CachedSLEs cachedSLEs_
Definition: Application.cpp:340
ripple::TxDBInit
constexpr std::array< char const *, 8 > TxDBInit
Definition: DBInit.h:82
std::max
T max(T... args)
ripple::NodeStore::Manager::make_Database
virtual std::unique_ptr< Database > make_Database(std::string const &name, Scheduler &scheduler, int readThreads, Stoppable &parent, Section const &backendParameters, beast::Journal journal)=0
Construct a NodeStore database.
ripple::NodeStore::Manager::instance
static Manager & instance()
Returns the instance of the manager singleton.
Definition: ManagerImp.cpp:117
ripple::WalletDBInit
constexpr std::array< char const *, 6 > WalletDBInit
Definition: DBInit.h:140
ripple::ApplicationImp::m_masterMutex
Application::MutexType m_masterMutex
Definition: Application.cpp:326
BasicApp::get_io_service
boost::asio::io_service & get_io_service()
Definition: BasicApp.h:41
ripple::ApplicationImp::initNodeStore
bool initNodeStore()
Definition: Application.cpp:1032
ripple::ApplicationImp::maxDisallowedLedger_
std::atomic< LedgerIndex > maxDisallowedLedger_
Definition: Application.cpp:1347
ripple::LedgerMaster::getHashBySeq
uint256 getHashBySeq(std::uint32_t index)
Get a ledger's hash by sequence number using the cache.
Definition: LedgerMaster.cpp:1557
ripple::ApplicationImp::publisherManifests_
std::unique_ptr< ManifestCache > publisherManifests_
Definition: Application.cpp:363
ripple::detail::AppFamily::app_
Application & app_
Definition: Application.cpp:90
ripple::AmendmentTable
The amendment table stores the list of enabled and potential amendments.
Definition: AmendmentTable.h:34
ripple::ApplicationImp::getMasterTransaction
TransactionMaster & getMasterTransaction() override
Definition: Application.cpp:760
ripple::make_InboundTransactions
std::unique_ptr< InboundTransactions > make_InboundTransactions(Application &app, Stoppable &parent, beast::insight::Collector::ptr const &collector, std::function< void(std::shared_ptr< SHAMap > const &, bool)> gotSet)
Definition: InboundTransactions.cpp:264
std::unique_ptr
STL class.
ripple::InboundLedger::Reason::SHARD
@ SHARD
ripple::TxDBPragma
constexpr std::array< char const *, 5 > TxDBPragma
Definition: DBInit.h:71
ripple::NetClock::time_point
std::chrono::time_point< NetClock > time_point
Definition: chrono.h:54
ripple::detail::AppFamily::isShardBacked
bool isShardBacked() const override
Definition: Application.cpp:189
ripple::Config::LOAD_FILE
@ LOAD_FILE
Definition: Config.h:122
ripple::ApplicationImp::io_latency_sampler::start
void start()
Definition: Application.cpp:277
std::condition_variable::notify_all
T notify_all(T... args)
Json::Value::isObjectOrNull
bool isObjectOrNull() const
Definition: json_value.cpp:1033
ripple::ApplicationImp::getValidations
RCLValidations & getValidations() override
Definition: Application.cpp:844
ripple::ApplicationImp::setEntropyTimer
void setEntropyTimer()
Definition: Application.cpp:1220
ripple::make_Application
std::unique_ptr< Application > make_Application(std::unique_ptr< Config > config, std::unique_ptr< Logs > logs, std::unique_ptr< TimeKeeper > timeKeeper)
Definition: Application.cpp:2348
ripple::detail::AppFamily::db
NodeStore::Database const & db() const override
Definition: Application.cpp:183
ripple::ValidatorKeys::manifest
std::string manifest
Definition: ValidatorKeys.h:42
std::ref
T ref(T... args)
ripple::make_ServerHandler
std::unique_ptr< ServerHandler > make_ServerHandler(Application &app, Stoppable &parent, boost::asio::io_service &io_service, JobQueue &jobQueue, NetworkOPs &networkOPs, Resource::Manager &resourceManager, CollectorManager &cm)
Definition: ServerHandlerImp.cpp:1155
std::exception::what
T what(T... args)
Json::Value
Represents a JSON value.
Definition: json_value.h:145
beast::insight::Event::notify
void notify(std::chrono::duration< Rep, Period > const &value) const
Push an event notification.
Definition: Event.h:66
ripple::ApplicationImp::logs_
std::unique_ptr< Logs > logs_
Definition: Application.cpp:321
ripple::InboundTransactions
Manages the acquisition and lifetime of transaction sets.
Definition: InboundTransactions.h:36
ripple::ApplicationImp::onPrepare
void onPrepare() override
Override called during preparation.
Definition: Application.cpp:1086
Json::Value::asString
std::string asString() const
Returns the unquoted string value.
Definition: json_value.cpp:469
std::ifstream
STL class.
ripple::LgrDBName
constexpr auto LgrDBName
Definition: DBInit.h:30
ripple::getRegisteredFeature
boost::optional< uint256 > getRegisteredFeature(std::string const &name)
Definition: Feature.cpp:140
beast
Definition: base_uint.h:646
std::chrono