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