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
353  // VFALCO TODO Make OrderBookDB abstract
375  boost::asio::steady_timer sweepTimer_;
376  boost::asio::steady_timer entropyTimer_;
378 
384 
385  boost::asio::signal_set m_signals;
386 
389  bool isTimeToStop = false;
390 
392 
394 
396 
398 
399  //--------------------------------------------------------------------------
400 
401  static std::size_t
403  {
404 #if RIPPLE_SINGLE_IO_SERVICE_THREAD
405  return 1;
406 #else
407  auto const cores = std::thread::hardware_concurrency();
408 
409  // Use a single thread when running on under-provisioned systems
410  // or if we are configured to use minimal resources.
411  if ((cores == 1) || ((config.NODE_SIZE == 0) && (cores == 2)))
412  return 1;
413 
414  // Otherwise, prefer two threads.
415  return 2;
416 #endif
417  }
418 
419  //--------------------------------------------------------------------------
420 
425  : RootStoppable("Application")
427  , config_(std::move(config))
428  , logs_(std::move(logs))
429  , timeKeeper_(std::move(timeKeeper))
430  , m_journal(logs_->journal("Application"))
431 
432  // PerfLog must be started before any other threads are launched.
433  , perfLog_(perf::make_PerfLog(
434  perf::setup_PerfLog(
435  config_->section("perf"),
436  config_->CONFIG_DIR),
437  *this,
438  logs_->journal("PerfLog"),
439  [this]() { signalStop(); }))
440 
441  , m_txMaster(*this)
442 
443  , m_nodeStoreScheduler(*this)
444 
446  *this,
447  *this,
449  logs_->journal("SHAMapStore")))
450 
451  , accountIDCache_(128000)
452 
453  , m_tempNodeCache(
454  "NodeCache",
455  16384,
457  stopwatch(),
458  logs_->journal("TaggedCache"))
459 
461  config_->section(SECTION_INSIGHT),
462  logs_->journal("Collector")))
465 
467  m_collectorManager->collector(),
468  logs_->journal("Resource")))
469 
470  // The JobQueue has to come pretty early since
471  // almost everything is a Stoppable child of the JobQueue.
472  //
473  , m_jobQueue(std::make_unique<JobQueue>(
474  m_collectorManager->group("jobq"),
476  logs_->journal("JobQueue"),
477  *logs_,
478  *perfLog_))
479 
480  , m_nodeStore(m_shaMapStore->makeNodeStore("NodeStore.main", 4))
481 
483 
484  // The shard store is optional and make_ShardStore can return null.
485  , shardStore_(make_ShardStore(
486  *this,
487  *m_jobQueue,
489  4,
490  logs_->journal("ShardStore")))
491 
492  , m_orderBookDB(*this, *m_jobQueue)
493 
494  , m_pathRequests(std::make_unique<PathRequests>(
495  *this,
496  logs_->journal("PathRequest"),
497  m_collectorManager->collector()))
498 
499  , m_ledgerMaster(std::make_unique<LedgerMaster>(
500  *this,
501  stopwatch(),
502  *m_jobQueue,
503  m_collectorManager->collector(),
504  logs_->journal("LedgerMaster")))
505 
506  // VFALCO NOTE must come before NetworkOPs to prevent a crash due
507  // to dependencies in the destructor.
508  //
510  *this,
511  stopwatch(),
512  *m_jobQueue,
513  m_collectorManager->collector()))
514 
516  *this,
517  *m_jobQueue,
518  m_collectorManager->collector(),
519  [this](std::shared_ptr<SHAMap> const& set, bool fromAcquire) {
520  gotTXSet(set, fromAcquire);
521  }))
522 
524  "AcceptedLedger",
525  4,
527  stopwatch(),
528  logs_->journal("TaggedCache"))
529 
531  *this,
532  stopwatch(),
533  config_->standalone(),
534  config_->NETWORK_QUORUM,
535  config_->START_VALID,
536  *m_jobQueue,
538  *m_jobQueue,
540  get_io_service(),
541  logs_->journal("NetworkOPs"),
542  m_collectorManager->collector()))
543 
544  , cluster_(std::make_unique<Cluster>(logs_->journal("Overlay")))
545 
546  , peerReservations_(std::make_unique<PeerReservationTable>(
547  logs_->journal("PeerReservationTable")))
548 
550  std::make_unique<ManifestCache>(logs_->journal("ManifestCache")))
551 
553  std::make_unique<ManifestCache>(logs_->journal("ManifestCache")))
554 
555  , validators_(std::make_unique<ValidatorList>(
558  *timeKeeper_,
559  config_->legacy("database_path"),
560  logs_->journal("ValidatorList"),
561  config_->VALIDATION_QUORUM))
562 
563  , validatorSites_(std::make_unique<ValidatorSite>(*this))
564 
566  *this,
567  *m_networkOPs,
568  get_io_service(),
569  *m_jobQueue,
570  *m_networkOPs,
573 
574  , mFeeTrack(
575  std::make_unique<LoadFeeTrack>(logs_->journal("LoadManager")))
576 
577  , hashRouter_(std::make_unique<HashRouter>(
578  stopwatch(),
581 
582  , mValidations(
583  ValidationParms(),
584  stopwatch(),
585  *this,
586  logs_->journal("Validations"))
587 
588  , m_loadManager(
589  make_LoadManager(*this, *this, logs_->journal("LoadManager")))
590 
591  , txQ_(
592  std::make_unique<TxQ>(setup_TxQ(*config_), logs_->journal("TxQ")))
593 
595 
597 
598  , startTimers_(false)
599 
601 
602  , checkSigs_(true)
603 
604  , m_resolver(
605  ResolverAsio::New(get_io_service(), logs_->journal("Resolver")))
606 
608  m_collectorManager->collector()->make_event("ios_latency"),
609  logs_->journal("Application"),
611  get_io_service())
612  , grpcServer_(std::make_unique<GRPCServer>(*this))
613  {
614  add(m_resourceManager.get());
615 
616  //
617  // VFALCO - READ THIS!
618  //
619  // Do not start threads, open sockets, or do any sort of "real work"
620  // inside the constructor. Put it in onStart instead. Or if you must,
621  // put it in setup (but everything in setup should be moved to onStart
622  // anyway.
623  //
624  // The reason is that the unit tests require an Application object to
625  // be created. But we don't actually start all the threads, sockets,
626  // and services when running the unit tests. Therefore anything which
627  // needs to be stopped will not get stopped correctly if it is
628  // started in this constructor.
629  //
630 
631  // VFALCO HACK
633 
634  add(m_ledgerMaster->getPropertySource());
635  }
636 
637  //--------------------------------------------------------------------------
638 
639  bool
640  setup() override;
641  void
642  doStart(bool withTimers) override;
643  void
644  run() override;
645  bool
646  isShutdown() override;
647  void
648  signalStop() override;
649  bool
650  checkSigs() const override;
651  void
652  checkSigs(bool) override;
653  int
654  fdRequired() const override;
655 
656  //--------------------------------------------------------------------------
657 
658  Logs&
659  logs() override
660  {
661  return *logs_;
662  }
663 
664  Config&
665  config() override
666  {
667  return *config_;
668  }
669 
672  {
673  return *m_collectorManager;
674  }
675 
676  Family&
677  family() override
678  {
679  return family_;
680  }
681 
682  Family*
683  shardFamily() override
684  {
685  return shardFamily_.get();
686  }
687 
688  TimeKeeper&
689  timeKeeper() override
690  {
691  return *timeKeeper_;
692  }
693 
694  JobQueue&
695  getJobQueue() override
696  {
697  return *m_jobQueue;
698  }
699 
701  nodeIdentity() override
702  {
703  return nodeIdentity_;
704  }
705 
706  PublicKey const&
707  getValidationPublicKey() const override
708  {
709  return validatorKeys_.publicKey;
710  }
711 
712  NetworkOPs&
713  getOPs() override
714  {
715  return *m_networkOPs;
716  }
717 
718  boost::asio::io_service&
719  getIOService() override
720  {
721  return get_io_service();
722  }
723 
725  getIOLatency() override
726  {
727  return m_io_latency_sampler.get();
728  }
729 
730  LedgerMaster&
731  getLedgerMaster() override
732  {
733  return *m_ledgerMaster;
734  }
735 
737  getInboundLedgers() override
738  {
739  return *m_inboundLedgers;
740  }
741 
744  {
745  return *m_inboundTransactions;
746  }
747 
750  {
751  return m_acceptedLedgerCache;
752  }
753 
754  void
755  gotTXSet(std::shared_ptr<SHAMap> const& set, bool fromAcquire)
756  {
757  if (set)
758  m_networkOPs->mapComplete(set, fromAcquire);
759  }
760 
763  {
764  return m_txMaster;
765  }
766 
768  getPerfLog() override
769  {
770  return *perfLog_;
771  }
772 
773  NodeCache&
774  getTempNodeCache() override
775  {
776  return m_tempNodeCache;
777  }
778 
780  getNodeStore() override
781  {
782  return *m_nodeStore;
783  }
784 
786  getShardStore() override
787  {
788  return shardStore_.get();
789  }
790 
792  getShardArchiveHandler(bool tryRecovery) override
793  {
794  static std::mutex handlerMutex;
795  std::lock_guard lock(handlerMutex);
796 
797  // After constructing the handler, try to
798  // initialize it. Log on error; set the
799  // member variable on success.
800  auto initAndSet =
802  if (!handler)
803  return false;
804 
805  if (!handler->init())
806  {
807  JLOG(m_journal.error())
808  << "Failed to initialize ShardArchiveHandler.";
809 
810  return false;
811  }
812 
813  shardArchiveHandler_ = std::move(handler);
814  return true;
815  };
816 
817  // Need to resume based on state from a previous
818  // run.
819  if (tryRecovery)
820  {
821  if (shardArchiveHandler_ != nullptr)
822  {
823  JLOG(m_journal.error())
824  << "ShardArchiveHandler already created at startup.";
825 
826  return nullptr;
827  }
828 
830  *this, *m_jobQueue);
831 
832  if (!initAndSet(std::move(handler)))
833  return nullptr;
834  }
835 
836  // Construct the ShardArchiveHandler
837  if (shardArchiveHandler_ == nullptr)
838  {
840  *this, *m_jobQueue);
841 
842  if (!initAndSet(std::move(handler)))
843  return nullptr;
844  }
845 
846  return shardArchiveHandler_.get();
847  }
848 
850  getMasterMutex() override
851  {
852  return m_masterMutex;
853  }
854 
855  LoadManager&
856  getLoadManager() override
857  {
858  return *m_loadManager;
859  }
860 
863  {
864  return *m_resourceManager;
865  }
866 
867  OrderBookDB&
868  getOrderBookDB() override
869  {
870  return m_orderBookDB;
871  }
872 
873  PathRequests&
874  getPathRequests() override
875  {
876  return *m_pathRequests;
877  }
878 
879  CachedSLEs&
880  cachedSLEs() override
881  {
882  return cachedSLEs_;
883  }
884 
886  getAmendmentTable() override
887  {
888  return *m_amendmentTable;
889  }
890 
891  LoadFeeTrack&
892  getFeeTrack() override
893  {
894  return *mFeeTrack;
895  }
896 
897  HashRouter&
898  getHashRouter() override
899  {
900  return *hashRouter_;
901  }
902 
904  getValidations() override
905  {
906  return mValidations;
907  }
908 
910  validators() override
911  {
912  return *validators_;
913  }
914 
916  validatorSites() override
917  {
918  return *validatorSites_;
919  }
920 
923  {
924  return *validatorManifests_;
925  }
926 
929  {
930  return *publisherManifests_;
931  }
932 
933  Cluster&
934  cluster() override
935  {
936  return *cluster_;
937  }
938 
940  peerReservations() override
941  {
942  return *peerReservations_;
943  }
944 
945  SHAMapStore&
946  getSHAMapStore() override
947  {
948  return *m_shaMapStore;
949  }
950 
951  PendingSaves&
952  pendingSaves() override
953  {
954  return pendingSaves_;
955  }
956 
957  AccountIDCache const&
958  accountIDCache() const override
959  {
960  return accountIDCache_;
961  }
962 
963  OpenLedger&
964  openLedger() override
965  {
966  return *openLedger_;
967  }
968 
969  OpenLedger const&
970  openLedger() const override
971  {
972  return *openLedger_;
973  }
974 
975  Overlay&
976  overlay() override
977  {
978  assert(overlay_);
979  return *overlay_;
980  }
981 
982  TxQ&
983  getTxQ() override
984  {
985  assert(txQ_.get() != nullptr);
986  return *txQ_;
987  }
988 
989  DatabaseCon&
990  getTxnDB() override
991  {
992  assert(mTxnDB.get() != nullptr);
993  return *mTxnDB;
994  }
995  DatabaseCon&
996  getLedgerDB() override
997  {
998  assert(mLedgerDB.get() != nullptr);
999  return *mLedgerDB;
1000  }
1001  DatabaseCon&
1002  getWalletDB() override
1003  {
1004  assert(mWalletDB.get() != nullptr);
1005  return *mWalletDB;
1006  }
1007 
1008  bool
1009  serverOkay(std::string& reason) override;
1010 
1012  journal(std::string const& name) override;
1013 
1014  //--------------------------------------------------------------------------
1015 
1016  bool
1018  {
1019  assert(mTxnDB.get() == nullptr);
1020  assert(mLedgerDB.get() == nullptr);
1021  assert(mWalletDB.get() == nullptr);
1022 
1023  try
1024  {
1025  auto const setup = setup_DatabaseCon(*config_);
1026 
1027  // transaction database
1028  mTxnDB = std::make_unique<DatabaseCon>(
1030  mTxnDB->getSession() << boost::str(
1031  boost::format("PRAGMA cache_size=-%d;") %
1032  kilobytes(config_->getValueFor(SizedItem::txnDBCache)));
1033  mTxnDB->setupCheckpointing(m_jobQueue.get(), logs());
1034 
1035  if (!setup.standAlone || setup.startUp == Config::LOAD ||
1036  setup.startUp == Config::LOAD_FILE ||
1037  setup.startUp == Config::REPLAY)
1038  {
1039  // Check if AccountTransactions has primary key
1040  std::string cid, name, type;
1041  std::size_t notnull, dflt_value, pk;
1042  soci::indicator ind;
1043  soci::statement st =
1044  (mTxnDB->getSession().prepare
1045  << ("PRAGMA table_info(AccountTransactions);"),
1046  soci::into(cid),
1047  soci::into(name),
1048  soci::into(type),
1049  soci::into(notnull),
1050  soci::into(dflt_value, ind),
1051  soci::into(pk));
1052 
1053  st.execute();
1054  while (st.fetch())
1055  {
1056  if (pk == 1)
1057  {
1058  JLOG(m_journal.fatal())
1059  << "AccountTransactions database "
1060  "should not have a primary key";
1061  return false;
1062  }
1063  }
1064  }
1065 
1066  // ledger database
1067  mLedgerDB = std::make_unique<DatabaseCon>(
1069  mLedgerDB->getSession() << boost::str(
1070  boost::format("PRAGMA cache_size=-%d;") %
1071  kilobytes(config_->getValueFor(SizedItem::lgrDBCache)));
1072  mLedgerDB->setupCheckpointing(m_jobQueue.get(), logs());
1073 
1074  // wallet database
1075  mWalletDB = std::make_unique<DatabaseCon>(
1076  setup,
1077  WalletDBName,
1079  WalletDBInit);
1080  }
1081  catch (std::exception const& e)
1082  {
1083  JLOG(m_journal.fatal())
1084  << "Failed to initialize SQLite databases: " << e.what();
1085  return false;
1086  }
1087 
1088  return true;
1089  }
1090 
1091  bool
1093  {
1094  if (config_->doImport)
1095  {
1096  auto j = logs_->journal("NodeObject");
1097  NodeStore::DummyScheduler dummyScheduler;
1098  RootStoppable dummyRoot{"DummyRoot"};
1101  "NodeStore.import",
1102  dummyScheduler,
1103  0,
1104  dummyRoot,
1106  j);
1107 
1108  JLOG(j.warn()) << "Starting node import from '" << source->getName()
1109  << "' to '" << m_nodeStore->getName() << "'.";
1110 
1111  using namespace std::chrono;
1112  auto const start = steady_clock::now();
1113 
1114  m_nodeStore->import(*source);
1115 
1116  auto const elapsed =
1117  duration_cast<seconds>(steady_clock::now() - start);
1118  JLOG(j.warn()) << "Node import from '" << source->getName()
1119  << "' took " << elapsed.count() << " seconds.";
1120  }
1121 
1122  // tune caches
1123  using namespace std::chrono;
1124  m_nodeStore->tune(
1125  config_->getValueFor(SizedItem::nodeCacheSize),
1126  seconds{config_->getValueFor(SizedItem::nodeCacheAge)});
1127 
1128  m_ledgerMaster->tune(
1129  config_->getValueFor(SizedItem::ledgerSize),
1130  seconds{config_->getValueFor(SizedItem::ledgerAge)});
1131 
1133  config_->getValueFor(SizedItem::treeCacheSize));
1135  seconds{config_->getValueFor(SizedItem::treeCacheAge)});
1136 
1137  return true;
1138  }
1139 
1140  //--------------------------------------------------------------------------
1141  //
1142  // Stoppable
1143  //
1144 
1145  void
1146  onPrepare() override
1147  {
1148  }
1149 
1150  void
1151  onStart() override
1152  {
1153  JLOG(m_journal.info()) << "Application starting. Version is "
1155 
1156  using namespace std::chrono_literals;
1157  if (startTimers_)
1158  {
1159  setSweepTimer();
1160  setEntropyTimer();
1161  }
1162 
1164 
1165  m_resolver->start();
1166  }
1167 
1168  // Called to indicate shutdown.
1169  void
1170  onStop() override
1171  {
1172  JLOG(m_journal.debug()) << "Application stopping";
1173 
1175 
1176  // VFALCO Enormous hack, we have to force the probe to cancel
1177  // before we stop the io_service queue or else it never
1178  // unblocks in its destructor. The fix is to make all
1179  // io_objects gracefully handle exit so that we can
1180  // naturally return from io_service::run() instead of
1181  // forcing a call to io_service::stop()
1183 
1184  m_resolver->stop_async();
1185 
1186  // NIKB This is a hack - we need to wait for the resolver to
1187  // stop. before we stop the io_server_queue or weird
1188  // things will happen.
1189  m_resolver->stop();
1190 
1191  {
1192  boost::system::error_code ec;
1193  sweepTimer_.cancel(ec);
1194  if (ec)
1195  {
1196  JLOG(m_journal.error())
1197  << "Application: sweepTimer cancel error: " << ec.message();
1198  }
1199 
1200  ec.clear();
1201  entropyTimer_.cancel(ec);
1202  if (ec)
1203  {
1204  JLOG(m_journal.error())
1205  << "Application: entropyTimer cancel error: "
1206  << ec.message();
1207  }
1208  }
1209  // Make sure that any waitHandlers pending in our timers are done
1210  // before we declare ourselves stopped.
1211  using namespace std::chrono_literals;
1212  waitHandlerCounter_.join("Application", 1s, m_journal);
1213 
1214  mValidations.flush();
1215 
1216  validatorSites_->stop();
1217 
1218  // TODO Store manifests in manifests.sqlite instead of wallet.db
1219  validatorManifests_->save(
1220  getWalletDB(),
1221  "ValidatorManifests",
1222  [this](PublicKey const& pubKey) {
1223  return validators().listed(pubKey);
1224  });
1225 
1226  publisherManifests_->save(
1227  getWalletDB(),
1228  "PublisherManifests",
1229  [this](PublicKey const& pubKey) {
1230  return validators().trustedPublisher(pubKey);
1231  });
1232 
1233  stopped();
1234  }
1235 
1236  //--------------------------------------------------------------------------
1237  //
1238  // PropertyStream
1239  //
1240 
1241  void
1243  {
1244  }
1245 
1246  //--------------------------------------------------------------------------
1247 
1248  void
1250  {
1251  // Only start the timer if waitHandlerCounter_ is not yet joined.
1252  if (auto optionalCountedHandler = waitHandlerCounter_.wrap(
1253  [this](boost::system::error_code const& e) {
1254  if ((e.value() == boost::system::errc::success) &&
1255  (!m_jobQueue->isStopped()))
1256  {
1257  m_jobQueue->addJob(
1258  jtSWEEP, "sweep", [this](Job&) { doSweep(); });
1259  }
1260  // Recover as best we can if an unexpected error occurs.
1261  if (e.value() != boost::system::errc::success &&
1262  e.value() != boost::asio::error::operation_aborted)
1263  {
1264  // Try again later and hope for the best.
1265  JLOG(m_journal.error())
1266  << "Sweep timer got error '" << e.message()
1267  << "'. Restarting timer.";
1268  setSweepTimer();
1269  }
1270  }))
1271  {
1272  using namespace std::chrono;
1273  sweepTimer_.expires_from_now(
1274  seconds{config_->getValueFor(SizedItem::sweepInterval)});
1275  sweepTimer_.async_wait(std::move(*optionalCountedHandler));
1276  }
1277  }
1278 
1279  void
1281  {
1282  // Only start the timer if waitHandlerCounter_ is not yet joined.
1283  if (auto optionalCountedHandler = waitHandlerCounter_.wrap(
1284  [this](boost::system::error_code const& e) {
1285  if (e.value() == boost::system::errc::success)
1286  {
1287  crypto_prng().mix_entropy();
1288  setEntropyTimer();
1289  }
1290  // Recover as best we can if an unexpected error occurs.
1291  if (e.value() != boost::system::errc::success &&
1292  e.value() != boost::asio::error::operation_aborted)
1293  {
1294  // Try again later and hope for the best.
1295  JLOG(m_journal.error())
1296  << "Entropy timer got error '" << e.message()
1297  << "'. Restarting timer.";
1298  setEntropyTimer();
1299  }
1300  }))
1301  {
1302  using namespace std::chrono_literals;
1303  entropyTimer_.expires_from_now(5min);
1304  entropyTimer_.async_wait(std::move(*optionalCountedHandler));
1305  }
1306  }
1307 
1308  void
1310  {
1311  if (!config_->standalone())
1312  {
1313  boost::filesystem::space_info space =
1314  boost::filesystem::space(config_->legacy("database_path"));
1315 
1316  if (space.available < megabytes(512))
1317  {
1318  JLOG(m_journal.fatal())
1319  << "Remaining free disk space is less than 512MB";
1320  signalStop();
1321  }
1322 
1324  boost::filesystem::path dbPath = dbSetup.dataDir / TxDBName;
1325  boost::system::error_code ec;
1326  boost::optional<std::uint64_t> dbSize =
1327  boost::filesystem::file_size(dbPath, ec);
1328  if (ec)
1329  {
1330  JLOG(m_journal.error())
1331  << "Error checking transaction db file size: "
1332  << ec.message();
1333  dbSize.reset();
1334  }
1335 
1336  auto db = mTxnDB->checkoutDb();
1337  static auto const pageSize = [&] {
1338  std::uint32_t ps;
1339  *db << "PRAGMA page_size;", soci::into(ps);
1340  return ps;
1341  }();
1342  static auto const maxPages = [&] {
1343  std::uint32_t mp;
1344  *db << "PRAGMA max_page_count;", soci::into(mp);
1345  return mp;
1346  }();
1347  std::uint32_t pageCount;
1348  *db << "PRAGMA page_count;", soci::into(pageCount);
1349  std::uint32_t freePages = maxPages - pageCount;
1350  std::uint64_t freeSpace =
1351  safe_cast<std::uint64_t>(freePages) * pageSize;
1352  JLOG(m_journal.info())
1353  << "Transaction DB pathname: " << dbPath.string()
1354  << "; file size: " << dbSize.value_or(-1) << " bytes"
1355  << "; SQLite page size: " << pageSize << " bytes"
1356  << "; Free pages: " << freePages
1357  << "; Free space: " << freeSpace << " bytes; "
1358  << "Note that this does not take into account available disk "
1359  "space.";
1360 
1361  if (freeSpace < megabytes(512))
1362  {
1363  JLOG(m_journal.fatal())
1364  << "Free SQLite space for transaction db is less than "
1365  "512MB. To fix this, rippled must be executed with the "
1366  "vacuum <sqlitetmpdir> parameter before restarting. "
1367  "Note that this activity can take multiple days, "
1368  "depending on database size.";
1369  signalStop();
1370  }
1371  }
1372 
1373  // VFALCO NOTE Does the order of calls matter?
1374  // VFALCO TODO fix the dependency inversion using an observer,
1375  // have listeners register for "onSweep ()" notification.
1376 
1377  family().fullbelow().sweep();
1378  if (shardFamily_)
1379  shardFamily_->fullbelow().sweep();
1381  getNodeStore().sweep();
1382  if (shardStore_)
1383  shardStore_->sweep();
1384  getLedgerMaster().sweep();
1385  getTempNodeCache().sweep();
1386  getValidations().expire();
1388  m_acceptedLedgerCache.sweep();
1389  family().treecache().sweep();
1390  if (shardFamily_)
1391  shardFamily_->treecache().sweep();
1392  cachedSLEs_.expire();
1393 
1394  // Set timer to do another sweep later.
1395  setSweepTimer();
1396  }
1397 
1398  LedgerIndex
1400  {
1401  return maxDisallowedLedger_;
1402  }
1403 
1404 private:
1405  // For a newly-started validator, this is the greatest persisted ledger
1406  // and new validations must be greater than this.
1408 
1409  bool
1410  nodeToShards();
1411  bool
1412  validateShards();
1413  void
1415 
1418 
1420  loadLedgerFromFile(std::string const& ledgerID);
1421 
1422  bool
1423  loadOldLedger(std::string const& ledgerID, bool replay, bool isFilename);
1424 
1425  void
1427 };
1428 
1429 //------------------------------------------------------------------------------
1430 
1431 // TODO Break this up into smaller, more digestible initialization segments.
1432 bool
1434 {
1435  // We want to intercept CTRL-C and the standard termination signal SIGTERM
1436  // and terminate the process. This handler will NEVER be invoked twice.
1437  //
1438  // Note that async_wait is "one-shot": for each call, the handler will be
1439  // invoked exactly once, either when one of the registered signals in the
1440  // signal set occurs or the signal set is cancelled. Subsequent signals are
1441  // effectively ignored (technically, they are queued up, waiting for a call
1442  // to async_wait).
1443  m_signals.add(SIGINT);
1444  m_signals.add(SIGTERM);
1445  m_signals.async_wait(
1446  [this](boost::system::error_code const& ec, int signum) {
1447  // Indicates the signal handler has been aborted; do nothing
1448  if (ec == boost::asio::error::operation_aborted)
1449  return;
1450 
1451  JLOG(m_journal.info()) << "Received signal " << signum;
1452 
1453  if (signum == SIGTERM || signum == SIGINT)
1454  signalStop();
1455  });
1456 
1457  assert(mTxnDB == nullptr);
1458 
1459  auto debug_log = config_->getDebugLogFile();
1460 
1461  if (!debug_log.empty())
1462  {
1463  // Let debug messages go to the file but only WARNING or higher to
1464  // regular output (unless verbose)
1465 
1466  if (!logs_->open(debug_log))
1467  std::cerr << "Can't open log file " << debug_log << '\n';
1468 
1469  using namespace beast::severities;
1470  if (logs_->threshold() > kDebug)
1471  logs_->threshold(kDebug);
1472  }
1473  JLOG(m_journal.info()) << "process starting: "
1475 
1476  if (numberOfThreads(*config_) < 2)
1477  {
1478  JLOG(m_journal.warn()) << "Limited to a single I/O service thread by "
1479  "system configuration.";
1480  }
1481 
1482  // Optionally turn off logging to console.
1483  logs_->silent(config_->silent());
1484 
1485  m_jobQueue->setThreadCount(config_->WORKERS, config_->standalone());
1486  grpcServer_->run();
1487 
1488  if (!config_->standalone())
1489  timeKeeper_->run(config_->SNTP_SERVERS);
1490 
1491  if (!initSQLiteDBs() || !initNodeStore())
1492  return false;
1493 
1494  if (shardStore_)
1495  {
1496  shardFamily_ = std::make_unique<detail::AppFamily>(
1497  *this, *shardStore_, *m_collectorManager);
1498 
1499  using namespace std::chrono;
1500  shardFamily_->treecache().setTargetSize(
1501  config_->getValueFor(SizedItem::treeCacheSize));
1502  shardFamily_->treecache().setTargetAge(
1503  seconds{config_->getValueFor(SizedItem::treeCacheAge)});
1504 
1505  if (!shardStore_->init())
1506  return false;
1507  }
1508 
1509  if (!peerReservations_->load(getWalletDB()))
1510  {
1511  JLOG(m_journal.fatal()) << "Cannot find peer reservations!";
1512  return false;
1513  }
1514 
1517 
1518  // Configure the amendments the server supports
1519  {
1520  auto const& sa = detail::supportedAmendments();
1521  std::vector<std::string> saHashes;
1522  saHashes.reserve(sa.size());
1523  for (auto const& name : sa)
1524  {
1525  auto const f = getRegisteredFeature(name);
1526  BOOST_ASSERT(f);
1527  if (f)
1528  saHashes.push_back(to_string(*f) + " " + name);
1529  }
1530  Section supportedAmendments("Supported Amendments");
1531  supportedAmendments.append(saHashes);
1532 
1533  Section enabledAmendments = config_->section(SECTION_AMENDMENTS);
1534 
1536  weeks{2},
1538  supportedAmendments,
1539  enabledAmendments,
1540  config_->section(SECTION_VETO_AMENDMENTS),
1541  logs_->journal("Amendments"));
1542  }
1543 
1545 
1546  auto const startUp = config_->START_UP;
1547  if (startUp == Config::FRESH)
1548  {
1549  JLOG(m_journal.info()) << "Starting new Ledger";
1550 
1552  }
1553  else if (
1554  startUp == Config::LOAD || startUp == Config::LOAD_FILE ||
1555  startUp == Config::REPLAY)
1556  {
1557  JLOG(m_journal.info()) << "Loading specified Ledger";
1558 
1559  if (!loadOldLedger(
1560  config_->START_LEDGER,
1561  startUp == Config::REPLAY,
1562  startUp == Config::LOAD_FILE))
1563  {
1564  JLOG(m_journal.error())
1565  << "The specified ledger could not be loaded.";
1566  return false;
1567  }
1568  }
1569  else if (startUp == Config::NETWORK)
1570  {
1571  // This should probably become the default once we have a stable
1572  // network.
1573  if (!config_->standalone())
1574  m_networkOPs->setNeedNetworkLedger();
1575 
1577  }
1578  else
1579  {
1581  }
1582 
1583  m_orderBookDB.setup(getLedgerMaster().getCurrentLedger());
1584 
1586 
1587  if (!cluster_->load(config().section(SECTION_CLUSTER_NODES)))
1588  {
1589  JLOG(m_journal.fatal()) << "Invalid entry in cluster configuration.";
1590  return false;
1591  }
1592 
1593  {
1595  return false;
1596 
1597  if (!validatorManifests_->load(
1598  getWalletDB(),
1599  "ValidatorManifests",
1601  config().section(SECTION_VALIDATOR_KEY_REVOCATION).values()))
1602  {
1603  JLOG(m_journal.fatal()) << "Invalid configured validator manifest.";
1604  return false;
1605  }
1606 
1607  publisherManifests_->load(getWalletDB(), "PublisherManifests");
1608 
1609  // Setup trusted validators
1610  if (!validators_->load(
1612  config().section(SECTION_VALIDATORS).values(),
1613  config().section(SECTION_VALIDATOR_LIST_KEYS).values()))
1614  {
1615  JLOG(m_journal.fatal())
1616  << "Invalid entry in validator configuration.";
1617  return false;
1618  }
1619  }
1620 
1621  if (!validatorSites_->load(
1622  config().section(SECTION_VALIDATOR_LIST_SITES).values()))
1623  {
1624  JLOG(m_journal.fatal())
1625  << "Invalid entry in [" << SECTION_VALIDATOR_LIST_SITES << "]";
1626  return false;
1627  }
1628 
1629  //----------------------------------------------------------------------
1630  //
1631  // Server
1632  //
1633  //----------------------------------------------------------------------
1634 
1635  // VFALCO NOTE Unfortunately, in stand-alone mode some code still
1636  // foolishly calls overlay(). When this is fixed we can
1637  // move the instantiation inside a conditional:
1638  //
1639  // if (!config_.standalone())
1641  *this,
1643  *m_jobQueue,
1644  *serverHandler_,
1646  *m_resolver,
1647  get_io_service(),
1648  *config_,
1649  m_collectorManager->collector());
1650  add(*overlay_); // add to PropertyStream
1651 
1652  if (!config_->standalone())
1653  {
1654  // validation and node import require the sqlite db
1655  if (config_->nodeToShard && !nodeToShards())
1656  return false;
1657 
1658  if (config_->validateShards && !validateShards())
1659  return false;
1660  }
1661 
1662  validatorSites_->start();
1663 
1664  // start first consensus round
1665  if (!m_networkOPs->beginConsensus(
1666  m_ledgerMaster->getClosedLedger()->info().hash))
1667  {
1668  JLOG(m_journal.fatal()) << "Unable to start consensus";
1669  return false;
1670  }
1671 
1672  {
1673  try
1674  {
1675  auto setup = setup_ServerHandler(
1677  setup.makeContexts();
1678  serverHandler_->setup(setup, m_journal);
1679  }
1680  catch (std::exception const& e)
1681  {
1682  if (auto stream = m_journal.fatal())
1683  {
1684  stream << "Unable to setup server handler";
1685  if (std::strlen(e.what()) > 0)
1686  stream << ": " << e.what();
1687  }
1688  return false;
1689  }
1690  }
1691 
1692  // Begin connecting to network.
1693  if (!config_->standalone())
1694  {
1695  // Should this message be here, conceptually? In theory this sort
1696  // of message, if displayed, should be displayed from PeerFinder.
1697  if (config_->PEER_PRIVATE && config_->IPS_FIXED.empty())
1698  {
1699  JLOG(m_journal.warn())
1700  << "No outbound peer connections will be made";
1701  }
1702 
1703  // VFALCO NOTE the state timer resets the deadlock detector.
1704  //
1705  m_networkOPs->setStateTimer();
1706  }
1707  else
1708  {
1709  JLOG(m_journal.warn()) << "Running in standalone mode";
1710 
1711  m_networkOPs->setStandAlone();
1712  }
1713 
1714  if (config_->canSign())
1715  {
1716  JLOG(m_journal.warn()) << "*** The server is configured to allow the "
1717  "'sign' and 'sign_for'";
1718  JLOG(m_journal.warn()) << "*** commands. These commands have security "
1719  "implications and have";
1720  JLOG(m_journal.warn()) << "*** been deprecated. They will be removed "
1721  "in a future release of";
1722  JLOG(m_journal.warn()) << "*** rippled.";
1723  JLOG(m_journal.warn()) << "*** If you do not use them to sign "
1724  "transactions please edit your";
1725  JLOG(m_journal.warn())
1726  << "*** configuration file and remove the [enable_signing] stanza.";
1727  JLOG(m_journal.warn()) << "*** If you do use them to sign transactions "
1728  "please migrate to a";
1729  JLOG(m_journal.warn())
1730  << "*** standalone signing solution as soon as possible.";
1731  }
1732 
1733  //
1734  // Execute start up rpc commands.
1735  //
1736  for (auto cmd : config_->section(SECTION_RPC_STARTUP).lines())
1737  {
1738  Json::Reader jrReader;
1739  Json::Value jvCommand;
1740 
1741  if (!jrReader.parse(cmd, jvCommand))
1742  {
1743  JLOG(m_journal.fatal()) << "Couldn't parse entry in ["
1744  << SECTION_RPC_STARTUP << "]: '" << cmd;
1745  }
1746 
1747  if (!config_->quiet())
1748  {
1749  JLOG(m_journal.fatal())
1750  << "Startup RPC: " << jvCommand << std::endl;
1751  }
1752 
1755  RPC::JsonContext context{
1756  {journal("RPCHandler"),
1757  *this,
1758  loadType,
1759  getOPs(),
1760  getLedgerMaster(),
1761  c,
1762  Role::ADMIN},
1763  jvCommand,
1765 
1766  Json::Value jvResult;
1767  RPC::doCommand(context, jvResult);
1768 
1769  if (!config_->quiet())
1770  {
1771  JLOG(m_journal.fatal()) << "Result: " << jvResult << std::endl;
1772  }
1773  }
1774 
1775  if (shardStore_)
1776  {
1777  try
1778  {
1779  // Create a ShardArchiveHandler if recovery
1780  // is needed (there's a state database left
1781  // over from a previous run).
1782  auto handler = getShardArchiveHandler(true);
1783 
1784  // Recovery is needed.
1785  if (handler)
1786  {
1787  if (!handler->start())
1788  {
1789  JLOG(m_journal.fatal())
1790  << "Failed to start ShardArchiveHandler.";
1791 
1792  return false;
1793  }
1794  }
1795  }
1796  catch (std::exception const& e)
1797  {
1798  JLOG(m_journal.fatal())
1799  << "Exception when starting ShardArchiveHandler from "
1800  "state database: "
1801  << e.what();
1802 
1803  return false;
1804  }
1805  }
1806 
1807  return true;
1808 }
1809 
1810 void
1811 ApplicationImp::doStart(bool withTimers)
1812 {
1813  startTimers_ = withTimers;
1814  prepare();
1815  start();
1816 }
1817 
1818 void
1820 {
1821  if (!config_->standalone())
1822  {
1823  // VFALCO NOTE This seems unnecessary. If we properly refactor the load
1824  // manager then the deadlock detector can just always be
1825  // "armed"
1826  //
1828  }
1829 
1830  {
1832  cv_.wait(lk, [this] { return isTimeToStop; });
1833  }
1834 
1835  // Stop the server. When this returns, all
1836  // Stoppable objects should be stopped.
1837  JLOG(m_journal.info()) << "Received shutdown request";
1838  stop(m_journal);
1839  JLOG(m_journal.info()) << "Done.";
1840 }
1841 
1842 void
1844 {
1845  // Unblock the main thread (which is sitting in run()).
1846  // When we get C++20 this can use std::latch.
1847  std::lock_guard lk{mut_};
1848 
1849  if (!isTimeToStop)
1850  {
1851  isTimeToStop = true;
1852  cv_.notify_all();
1853  }
1854 }
1855 
1856 bool
1858 {
1859  // from Stoppable mixin
1860  return isStopped();
1861 }
1862 
1863 bool
1865 {
1866  return checkSigs_;
1867 }
1868 
1869 void
1871 {
1872  checkSigs_ = check;
1873 }
1874 
1875 int
1877 {
1878  // Standard handles, config file, misc I/O etc:
1879  int needed = 128;
1880 
1881  // 2x the configured peer limit for peer connections:
1882  needed += 2 * overlay_->limit();
1883 
1884  // the number of fds needed by the backend (internally
1885  // doubled if online delete is enabled).
1886  needed += std::max(5, m_shaMapStore->fdRequired());
1887 
1888  if (shardStore_)
1889  needed += shardStore_->fdRequired();
1890 
1891  // One fd per incoming connection a port can accept, or
1892  // if no limit is set, assume it'll handle 256 clients.
1893  for (auto const& p : serverHandler_->setup().ports)
1894  needed += std::max(256, p.limit);
1895 
1896  // The minimum number of file descriptors we need is 1024:
1897  return std::max(1024, needed);
1898 }
1899 
1900 //------------------------------------------------------------------------------
1901 
1902 void
1904 {
1905  std::vector<uint256> initialAmendments =
1906  (config_->START_UP == Config::FRESH) ? m_amendmentTable->getDesired()
1908 
1909  std::shared_ptr<Ledger> const genesis = std::make_shared<Ledger>(
1910  create_genesis, *config_, initialAmendments, family());
1911  m_ledgerMaster->storeLedger(genesis);
1912 
1913  auto const next =
1914  std::make_shared<Ledger>(*genesis, timeKeeper().closeTime());
1915  next->updateSkipList();
1916  next->setImmutable(*config_);
1917  openLedger_.emplace(next, cachedSLEs_, logs_->journal("OpenLedger"));
1918  m_ledgerMaster->storeLedger(next);
1919  m_ledgerMaster->switchLCL(next);
1920 }
1921 
1924 {
1925  auto j = journal("Ledger");
1926 
1927  try
1928  {
1929  auto const [ledger, seq, hash] =
1930  loadLedgerHelper("order by LedgerSeq desc limit 1", *this);
1931 
1932  if (!ledger)
1933  return ledger;
1934 
1935  ledger->setImmutable(*config_);
1936 
1937  if (getLedgerMaster().haveLedger(seq))
1938  ledger->setValidated();
1939 
1940  if (ledger->info().hash == hash)
1941  {
1942  JLOG(j.trace()) << "Loaded ledger: " << hash;
1943  return ledger;
1944  }
1945 
1946  if (auto stream = j.error())
1947  {
1948  stream << "Failed on ledger";
1949  Json::Value p;
1950  addJson(p, {*ledger, LedgerFill::full});
1951  stream << p;
1952  }
1953 
1954  return {};
1955  }
1956  catch (SHAMapMissingNode const& mn)
1957  {
1958  JLOG(j.warn()) << "Ledger in database: " << mn.what();
1959  return {};
1960  }
1961 }
1962 
1965 {
1966  try
1967  {
1968  std::ifstream ledgerFile(name, std::ios::in);
1969 
1970  if (!ledgerFile)
1971  {
1972  JLOG(m_journal.fatal()) << "Unable to open file '" << name << "'";
1973  return nullptr;
1974  }
1975 
1976  Json::Reader reader;
1977  Json::Value jLedger;
1978 
1979  if (!reader.parse(ledgerFile, jLedger))
1980  {
1981  JLOG(m_journal.fatal()) << "Unable to parse ledger JSON";
1982  return nullptr;
1983  }
1984 
1985  std::reference_wrapper<Json::Value> ledger(jLedger);
1986 
1987  // accept a wrapped ledger
1988  if (ledger.get().isMember("result"))
1989  ledger = ledger.get()["result"];
1990 
1991  if (ledger.get().isMember("ledger"))
1992  ledger = ledger.get()["ledger"];
1993 
1994  std::uint32_t seq = 1;
1995  auto closeTime = timeKeeper().closeTime();
1996  using namespace std::chrono_literals;
1997  auto closeTimeResolution = 30s;
1998  bool closeTimeEstimated = false;
1999  std::uint64_t totalDrops = 0;
2000 
2001  if (ledger.get().isMember("accountState"))
2002  {
2003  if (ledger.get().isMember(jss::ledger_index))
2004  {
2005  seq = ledger.get()[jss::ledger_index].asUInt();
2006  }
2007 
2008  if (ledger.get().isMember("close_time"))
2009  {
2010  using tp = NetClock::time_point;
2011  using d = tp::duration;
2012  closeTime = tp{d{ledger.get()["close_time"].asUInt()}};
2013  }
2014  if (ledger.get().isMember("close_time_resolution"))
2015  {
2016  using namespace std::chrono;
2017  closeTimeResolution =
2018  seconds{ledger.get()["close_time_resolution"].asUInt()};
2019  }
2020  if (ledger.get().isMember("close_time_estimated"))
2021  {
2022  closeTimeEstimated =
2023  ledger.get()["close_time_estimated"].asBool();
2024  }
2025  if (ledger.get().isMember("total_coins"))
2026  {
2027  totalDrops = beast::lexicalCastThrow<std::uint64_t>(
2028  ledger.get()["total_coins"].asString());
2029  }
2030 
2031  ledger = ledger.get()["accountState"];
2032  }
2033 
2034  if (!ledger.get().isArrayOrNull())
2035  {
2036  JLOG(m_journal.fatal()) << "State nodes must be an array";
2037  return nullptr;
2038  }
2039 
2040  auto loadLedger =
2041  std::make_shared<Ledger>(seq, closeTime, *config_, family());
2042  loadLedger->setTotalDrops(totalDrops);
2043 
2044  for (Json::UInt index = 0; index < ledger.get().size(); ++index)
2045  {
2046  Json::Value& entry = ledger.get()[index];
2047 
2048  if (!entry.isObjectOrNull())
2049  {
2050  JLOG(m_journal.fatal()) << "Invalid entry in ledger";
2051  return nullptr;
2052  }
2053 
2054  uint256 uIndex;
2055 
2056  if (!uIndex.SetHex(entry[jss::index].asString()))
2057  {
2058  JLOG(m_journal.fatal()) << "Invalid entry in ledger";
2059  return nullptr;
2060  }
2061 
2062  entry.removeMember(jss::index);
2063 
2064  STParsedJSONObject stp("sle", ledger.get()[index]);
2065 
2066  if (!stp.object || uIndex.isZero())
2067  {
2068  JLOG(m_journal.fatal()) << "Invalid entry in ledger";
2069  return nullptr;
2070  }
2071 
2072  // VFALCO TODO This is the only place that
2073  // constructor is used, try to remove it
2074  STLedgerEntry sle(*stp.object, uIndex);
2075 
2076  if (!loadLedger->addSLE(sle))
2077  {
2078  JLOG(m_journal.fatal())
2079  << "Couldn't add serialized ledger: " << uIndex;
2080  return nullptr;
2081  }
2082  }
2083 
2084  loadLedger->stateMap().flushDirty(
2085  hotACCOUNT_NODE, loadLedger->info().seq);
2086 
2087  loadLedger->setAccepted(
2088  closeTime, closeTimeResolution, !closeTimeEstimated, *config_);
2089 
2090  return loadLedger;
2091  }
2092  catch (std::exception const& x)
2093  {
2094  JLOG(m_journal.fatal()) << "Ledger contains invalid data: " << x.what();
2095  return nullptr;
2096  }
2097 }
2098 
2099 bool
2101  std::string const& ledgerID,
2102  bool replay,
2103  bool isFileName)
2104 {
2105  try
2106  {
2107  std::shared_ptr<Ledger const> loadLedger, replayLedger;
2108 
2109  if (isFileName)
2110  {
2111  if (!ledgerID.empty())
2112  loadLedger = loadLedgerFromFile(ledgerID);
2113  }
2114  else if (ledgerID.length() == 64)
2115  {
2116  uint256 hash;
2117 
2118  if (hash.SetHex(ledgerID))
2119  {
2120  loadLedger = loadByHash(hash, *this);
2121 
2122  if (!loadLedger)
2123  {
2124  // Try to build the ledger from the back end
2125  auto il = std::make_shared<InboundLedger>(
2126  *this,
2127  hash,
2128  0,
2130  stopwatch());
2131  if (il->checkLocal())
2132  loadLedger = il->getLedger();
2133  }
2134  }
2135  }
2136  else if (ledgerID.empty() || boost::iequals(ledgerID, "latest"))
2137  {
2138  loadLedger = getLastFullLedger();
2139  }
2140  else
2141  {
2142  // assume by sequence
2143  std::uint32_t index;
2144 
2145  if (beast::lexicalCastChecked(index, ledgerID))
2146  loadLedger = loadByIndex(index, *this);
2147  }
2148 
2149  if (!loadLedger)
2150  return false;
2151 
2152  if (replay)
2153  {
2154  // Replay a ledger close with same prior ledger and transactions
2155 
2156  // this ledger holds the transactions we want to replay
2157  replayLedger = loadLedger;
2158 
2159  JLOG(m_journal.info()) << "Loading parent ledger";
2160 
2161  loadLedger = loadByHash(replayLedger->info().parentHash, *this);
2162  if (!loadLedger)
2163  {
2164  JLOG(m_journal.info())
2165  << "Loading parent ledger from node store";
2166 
2167  // Try to build the ledger from the back end
2168  auto il = std::make_shared<InboundLedger>(
2169  *this,
2170  replayLedger->info().parentHash,
2171  0,
2173  stopwatch());
2174 
2175  if (il->checkLocal())
2176  loadLedger = il->getLedger();
2177 
2178  if (!loadLedger)
2179  {
2180  JLOG(m_journal.fatal()) << "Replay ledger missing/damaged";
2181  assert(false);
2182  return false;
2183  }
2184  }
2185  }
2186  using namespace std::chrono_literals;
2187  using namespace date;
2188  static constexpr NetClock::time_point ledgerWarnTimePoint{
2189  sys_days{January / 1 / 2018} - sys_days{January / 1 / 2000}};
2190  if (loadLedger->info().closeTime < ledgerWarnTimePoint)
2191  {
2192  JLOG(m_journal.fatal())
2193  << "\n\n*** WARNING ***\n"
2194  "You are replaying a ledger from before "
2195  << to_string(ledgerWarnTimePoint)
2196  << " UTC.\n"
2197  "This replay will not handle your ledger as it was "
2198  "originally "
2199  "handled.\nConsider running an earlier version of rippled "
2200  "to "
2201  "get the older rules.\n*** CONTINUING ***\n";
2202  }
2203 
2204  JLOG(m_journal.info()) << "Loading ledger " << loadLedger->info().hash
2205  << " seq:" << loadLedger->info().seq;
2206 
2207  if (loadLedger->info().accountHash.isZero())
2208  {
2209  JLOG(m_journal.fatal()) << "Ledger is empty.";
2210  assert(false);
2211  return false;
2212  }
2213 
2214  if (!loadLedger->walkLedger(journal("Ledger")))
2215  {
2216  JLOG(m_journal.fatal()) << "Ledger is missing nodes.";
2217  assert(false);
2218  return false;
2219  }
2220 
2221  if (!loadLedger->assertSane(journal("Ledger")))
2222  {
2223  JLOG(m_journal.fatal()) << "Ledger is not sane.";
2224  assert(false);
2225  return false;
2226  }
2227 
2228  m_ledgerMaster->setLedgerRangePresent(
2229  loadLedger->info().seq, loadLedger->info().seq);
2230 
2231  m_ledgerMaster->switchLCL(loadLedger);
2232  loadLedger->setValidated();
2233  m_ledgerMaster->setFullLedger(loadLedger, true, false);
2234  openLedger_.emplace(
2235  loadLedger, cachedSLEs_, logs_->journal("OpenLedger"));
2236 
2237  if (replay)
2238  {
2239  // inject transaction(s) from the replayLedger into our open ledger
2240  // and build replay structure
2241  auto replayData =
2242  std::make_unique<LedgerReplay>(loadLedger, replayLedger);
2243 
2244  for (auto const& [_, tx] : replayData->orderedTxns())
2245  {
2246  (void)_;
2247  auto txID = tx->getTransactionID();
2248 
2249  auto s = std::make_shared<Serializer>();
2250  tx->add(*s);
2251 
2253 
2254  openLedger_->modify(
2255  [&txID, &s](OpenView& view, beast::Journal j) {
2256  view.rawTxInsert(txID, std::move(s), nullptr);
2257  return true;
2258  });
2259  }
2260 
2261  m_ledgerMaster->takeReplay(std::move(replayData));
2262  }
2263  }
2264  catch (SHAMapMissingNode const& mn)
2265  {
2266  JLOG(m_journal.fatal())
2267  << "While loading specified ledger: " << mn.what();
2268  return false;
2269  }
2270  catch (boost::bad_lexical_cast&)
2271  {
2272  JLOG(m_journal.fatal())
2273  << "Ledger specified '" << ledgerID << "' is not valid";
2274  return false;
2275  }
2276 
2277  return true;
2278 }
2279 
2280 bool
2282 {
2283  if (!config().ELB_SUPPORT)
2284  return true;
2285 
2286  if (isShutdown())
2287  {
2288  reason = "Server is shutting down";
2289  return false;
2290  }
2291 
2292  if (getOPs().isNeedNetworkLedger())
2293  {
2294  reason = "Not synchronized with network yet";
2295  return false;
2296  }
2297 
2298  if (getOPs().getOperatingMode() < OperatingMode::SYNCING)
2299  {
2300  reason = "Not synchronized with network";
2301  return false;
2302  }
2303 
2304  if (!getLedgerMaster().isCaughtUp(reason))
2305  return false;
2306 
2307  if (getFeeTrack().isLoadedLocal())
2308  {
2309  reason = "Too much load";
2310  return false;
2311  }
2312 
2313  if (getOPs().isAmendmentBlocked())
2314  {
2315  reason = "Server version too old";
2316  return false;
2317  }
2318 
2319  return true;
2320 }
2321 
2324 {
2325  return logs_->journal(name);
2326 }
2327 
2328 bool
2330 {
2331  assert(overlay_);
2332  assert(!config_->standalone());
2333 
2334  if (config_->section(ConfigSection::shardDatabase()).empty())
2335  {
2336  JLOG(m_journal.fatal())
2337  << "The [shard_db] configuration setting must be set";
2338  return false;
2339  }
2340  if (!shardStore_)
2341  {
2342  JLOG(m_journal.fatal()) << "Invalid [shard_db] configuration";
2343  return false;
2344  }
2345  shardStore_->import(getNodeStore());
2346  return true;
2347 }
2348 
2349 bool
2351 {
2352  assert(overlay_);
2353  assert(!config_->standalone());
2354 
2355  if (config_->section(ConfigSection::shardDatabase()).empty())
2356  {
2357  JLOG(m_journal.fatal())
2358  << "The [shard_db] configuration setting must be set";
2359  return false;
2360  }
2361  if (!shardStore_)
2362  {
2363  JLOG(m_journal.fatal()) << "Invalid [shard_db] configuration";
2364  return false;
2365  }
2366  shardStore_->validate();
2367  return true;
2368 }
2369 
2370 void
2372 {
2373  boost::optional<LedgerIndex> seq;
2374  {
2375  auto db = getLedgerDB().checkoutDb();
2376  *db << "SELECT MAX(LedgerSeq) FROM Ledgers;", soci::into(seq);
2377  }
2378  if (seq)
2379  maxDisallowedLedger_ = *seq;
2380 
2381  JLOG(m_journal.trace())
2382  << "Max persisted ledger is " << maxDisallowedLedger_;
2383 }
2384 
2385 //------------------------------------------------------------------------------
2386 
2387 Application::Application() : beast::PropertyStream::Source("app")
2388 {
2389 }
2390 
2391 //------------------------------------------------------------------------------
2392 
2395  std::unique_ptr<Config> config,
2396  std::unique_ptr<Logs> logs,
2397  std::unique_ptr<TimeKeeper> timeKeeper)
2398 {
2399  return std::make_unique<ApplicationImp>(
2400  std::move(config), std::move(logs), std::move(timeKeeper));
2401 }
2402 
2403 } // 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:990
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:379
ripple::ApplicationImp::getValidationPublicKey
PublicKey const & getValidationPublicKey() const override
Definition: Application.cpp:707
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:1009
ripple::Application
Definition: Application.h:97
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:996
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:358
ripple::ApplicationImp::websocketServers_
std::vector< std::unique_ptr< Stoppable > > websocketServers_
Definition: Application.cpp:383
ripple::LoadManager
Manages load sources.
Definition: LoadManager.h:43
ripple::ApplicationImp::validators
ValidatorList & validators() override
Definition: Application.cpp:910
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:880
std::shared_ptr
STL class.
ripple::ApplicationImp::getNodeStore
NodeStore::Database & getNodeStore() override
Definition: Application.cpp:780
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:2281
ripple::loadByIndex
std::shared_ptr< Ledger > loadByIndex(std::uint32_t ledgerIndex, Application &app, bool acquire)
Definition: Ledger.cpp:1101
ripple::detail::AppFamily::shardBacked_
const bool shardBacked_
Definition: Application.cpp:94
ripple::LedgerMaster::sweep
void sweep()
Definition: LedgerMaster.cpp:1681
ripple::ApplicationImp::mValidations
RCLValidations mValidations
Definition: Application.cpp:371
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:749
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:898
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:366
ripple::ApplicationImp::mWalletDB
std::unique_ptr< DatabaseCon > mWalletDB
Definition: Application.cpp:381
ripple::SizedItem::nodeCacheSize
@ nodeCacheSize
ripple::ApplicationImp::getPathRequests
PathRequests & getPathRequests() override
Definition: Application.cpp:874
ripple::TaggedCache::sweep
void sweep()
Definition: TaggedCache.h:169
ripple::ApplicationImp::m_orderBookDB
OrderBookDB m_orderBookDB
Definition: Application.cpp:354
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:1170
ripple::detail::BasicFullBelowCache< uint256 >
ripple::ApplicationImp::onWrite
void onWrite(beast::PropertyStream::Map &stream) override
Subclass override.
Definition: Application.cpp:1242
ripple::LedgerMaster
Definition: LedgerMaster.h:54
ripple::ApplicationImp::getInboundLedgers
InboundLedgers & getInboundLedgers() override
Definition: Application.cpp:737
ripple::ApplicationImp::accountIDCache
AccountIDCache const & accountIDCache() const override
Definition: Application.cpp:958
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::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:667
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:374
ripple::ApplicationImp::getOPs
NetworkOPs & getOPs() override
Definition: Application.cpp:713
ripple::ApplicationImp::run
void run() override
Definition: Application.cpp:1819
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:1447
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:166
ripple::ApplicationImp::m_acceptedLedgerCache
TaggedCache< uint256, AcceptedLedger > m_acceptedLedgerCache
Definition: Application.cpp:359
ripple::ApplicationImp::setup
bool setup() override
Definition: Application.cpp:1433
ripple::SHAMapStore
class to create database, launch online delete thread, and related SQLite database
Definition: SHAMapStore.h:37
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:922
ripple::ApplicationImp::getWalletDB
DatabaseCon & getWalletDB() override
Retrieve the "wallet database".
Definition: Application.cpp:1002
ripple::ApplicationImp::getCollectorManager
CollectorManager & getCollectorManager() override
Definition: Application.cpp:671
ripple::ApplicationImp::sweepTimer_
boost::asio::steady_timer sweepTimer_
Definition: Application.cpp:375
ripple::ApplicationImp::cluster_
std::unique_ptr< Cluster > cluster_
Definition: Application.cpp:361
ripple::ApplicationImp::getShardStore
NodeStore::DatabaseShard * getShardStore() override
Definition: Application.cpp:786
ripple::ApplicationImp::openLedger
OpenLedger const & openLedger() const override
Definition: Application.cpp:970
ripple::ApplicationImp::getIOLatency
std::chrono::milliseconds getIOLatency() override
Definition: Application.cpp:725
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:719
ripple::ApplicationImp::shardArchiveHandler_
std::unique_ptr< RPC::ShardArchiveHandler > shardArchiveHandler_
Definition: Application.cpp:352
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:421
ripple::ApplicationImp::signalStop
void signalStop() override
Definition: Application.cpp:1843
ripple::ApplicationImp::cluster
Cluster & cluster() override
Definition: Application.cpp:934
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:731
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:677
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:380
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:1151
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:387
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::ApplicationImp::getShardArchiveHandler
RPC::ShardArchiveHandler * getShardArchiveHandler(bool tryRecovery) override
Definition: Application.cpp:792
ripple::detail::AppFamily::operator=
AppFamily & operator=(AppFamily const &)=delete
ripple::ApplicationImp::m_inboundLedgers
std::unique_ptr< InboundLedgers > m_inboundLedgers
Definition: Application.cpp:357
ripple::ApplicationImp::peerReservations_
std::unique_ptr< PeerReservationTable > peerReservations_
Definition: Application.cpp:362
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:1964
ripple::ApplicationImp::checkSigs
bool checkSigs() const override
Definition: Application.cpp:1864
ripple::ApplicationImp::journal
beast::Journal journal(std::string const &name) override
Definition: Application.cpp:2323
ripple::ApplicationImp::startTimers_
bool startTimers_
Definition: Application.cpp:377
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:3894
ripple::ApplicationImp::entropyTimer_
boost::asio::steady_timer entropyTimer_
Definition: Application.cpp:376
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:1399
ripple::ApplicationImp::nodeToShards
bool nodeToShards()
Definition: Application.cpp:2329
ripple::ApplicationImp::hashRouter_
std::unique_ptr< HashRouter > hashRouter_
Definition: Application.cpp:370
ripple::ApplicationImp::getMasterMutex
Application::MutexType & getMasterMutex() override
Definition: Application.cpp:850
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:356
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:1342
ripple::ApplicationImp::logs
Logs & logs() override
Definition: Application.cpp:659
ripple::ApplicationImp::getPerfLog
perf::PerfLog & getPerfLog() override
Definition: Application.cpp:768
ripple::ApplicationImp::m_jobQueue
std::unique_ptr< JobQueue > m_jobQueue
Definition: Application.cpp:347
ripple::ApplicationImp::checkSigs_
std::atomic< bool > checkSigs_
Definition: Application.cpp:391
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:1116
ripple::TxQ
Transaction Queue.
Definition: TxQ.h:54
ripple::ApplicationImp::numberOfThreads
static std::size_t numberOfThreads(Config const &config)
Definition: Application.cpp:402
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:946
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:886
ripple::ApplicationImp::loadOldLedger
bool loadOldLedger(std::string const &ledgerID, bool replay, bool isFilename)
Definition: Application.cpp:2100
ripple::ApplicationImp::initSQLiteDBs
bool initSQLiteDBs()
Definition: Application.cpp:1017
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:862
ripple::ApplicationImp::peerReservations
PeerReservationTable & peerReservations() override
Definition: Application.cpp:940
ripple::ApplicationImp::publisherManifests
ManifestCache & publisherManifests() override
Definition: Application.cpp:928
ripple::ApplicationImp::doStart
void doStart(bool withTimers) override
Definition: Application.cpp:1811
ripple::ApplicationImp::m_amendmentTable
std::unique_ptr< AmendmentTable > m_amendmentTable
Definition: Application.cpp:368
ripple::Config::NETWORK
@ NETWORK
Definition: Config.h:122
ripple::ApplicationImp::overlay
Overlay & overlay() override
Definition: Application.cpp:976
ripple::megabytes
constexpr auto megabytes(T value) noexcept
Definition: ByteUtilities.h:34
ripple::ApplicationImp::pendingSaves
PendingSaves & pendingSaves() override
Definition: Application.cpp:952
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:2350
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:388
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:916
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:701
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:1923
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:389
ripple::ApplicationImp::m_io_latency_sampler
io_latency_sampler m_io_latency_sampler
Definition: Application.cpp:395
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:1857
ripple::ApplicationImp::gotTXSet
void gotTXSet(std::shared_ptr< SHAMap > const &set, bool fromAcquire)
Definition: Application.cpp:755
std::atomic< std::chrono::milliseconds >
ripple::ApplicationImp::startGenesisLedger
void startGenesisLedger()
Definition: Application.cpp:1903
ripple::ApplicationImp::m_signals
boost::asio::signal_set m_signals
Definition: Application.cpp:385
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:689
beast::io_latency_probe< std::chrono::steady_clock >
ripple::RPC::ShardArchiveHandler::makeShardArchiveHandler
static std::unique_ptr< ShardArchiveHandler > makeShardArchiveHandler(Application &app, Stoppable &parent)
Definition: ShardArchiveHandler.cpp:48
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::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:2387
ripple::detail::AppFamily::fullbelow
FullBelowCache const & fullbelow() const override
Definition: Application.cpp:159
ripple::ApplicationImp::setMaxDisallowedLedger
void setMaxDisallowedLedger()
Definition: Application.cpp:2371
ripple::RPC::ShardArchiveHandler::tryMakeRecoveryHandler
static std::unique_ptr< ShardArchiveHandler > tryMakeRecoveryHandler(Application &app, Stoppable &parent)
Definition: ShardArchiveHandler.cpp:56
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:683
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:1249
ripple::ApplicationImp::overlay_
std::unique_ptr< Overlay > overlay_
Definition: Application.cpp:382
ripple::BuildInfo::getFullVersionString
std::string const & getFullVersionString()
Full server version string.
Definition: BuildInfo.cpp:74
ripple::ApplicationImp::openLedger
OpenLedger & openLedger() override
Definition: Application.cpp:964
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:393
ripple::ApplicationImp::getTxQ
TxQ & getTxQ() override
Definition: Application.cpp:983
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:774
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:397
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:695
ripple::ApplicationImp::fdRequired
int fdRequired() const override
Definition: Application.cpp:1876
ripple::ApplicationImp::doSweep
void doSweep()
Definition: Application.cpp:1309
ripple::make_SHAMapStore
std::unique_ptr< SHAMapStore > make_SHAMapStore(Application &app, Stoppable &parent, NodeStore::Scheduler &scheduler, beast::Journal journal)
Definition: SHAMapStoreImp.cpp:734
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:868
ripple::ApplicationImp
Definition: Application.cpp:252
ripple::ApplicationImp::getLoadManager
LoadManager & getLoadManager() override
Definition: Application.cpp:856
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:372
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:743
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:369
ripple::MAJORITY_FRACTION
static const int MAJORITY_FRACTION(204)
ripple::ApplicationImp::getFeeTrack
LoadFeeTrack & getFeeTrack() override
Definition: Application.cpp:892
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
Handles the download and import of one or more shard archives.
Definition: ShardArchiveHandler.h:39
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:665
ripple::ApplicationImp::validators_
std::unique_ptr< ValidatorList > validators_
Definition: Application.cpp:365
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:367
std::size_t
ripple::Family::fullbelow
virtual FullBelowCache & fullbelow()=0
ripple::ApplicationImp::validatorManifests_
std::unique_ptr< ManifestCache > validatorManifests_
Definition: Application.cpp:363
BasicApp
Definition: BasicApp.h:29
ripple::ApplicationImp::m_pathRequests
std::unique_ptr< PathRequests > m_pathRequests
Definition: Application.cpp:355
ripple::ApplicationImp::m_networkOPs
std::unique_ptr< NetworkOPs > m_networkOPs
Definition: Application.cpp:360
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:373
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:1092
ripple::ApplicationImp::maxDisallowedLedger_
std::atomic< LedgerIndex > maxDisallowedLedger_
Definition: Application.cpp:1407
ripple::LedgerMaster::getHashBySeq
uint256 getHashBySeq(std::uint32_t index)
Get a ledger's hash by sequence number using the cache.
Definition: LedgerMaster.cpp:1539
ripple::ApplicationImp::publisherManifests_
std::unique_ptr< ManifestCache > publisherManifests_
Definition: Application.cpp:364
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:762
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:904
ripple::ApplicationImp::setEntropyTimer
void setEntropyTimer()
Definition: Application.cpp:1280
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:2394
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:1146
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