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