rippled
Application.h
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 #ifndef RIPPLE_APP_MAIN_APPLICATION_H_INCLUDED
21 #define RIPPLE_APP_MAIN_APPLICATION_H_INCLUDED
22 
23 #include <ripple/basics/TaggedCache.h>
24 #include <ripple/beast/utility/PropertyStream.h>
25 #include <ripple/core/Config.h>
26 #include <ripple/overlay/PeerReservationTable.h>
27 #include <ripple/protocol/Protocol.h>
28 #include <ripple/shamap/FullBelowCache.h>
29 #include <ripple/shamap/TreeNodeCache.h>
30 #include <boost/asio.hpp>
31 #include <boost/program_options.hpp>
32 #include <memory>
33 #include <mutex>
34 
35 namespace ripple {
36 
37 namespace unl {
38 class Manager;
39 }
40 namespace Resource {
41 class Manager;
42 }
43 namespace NodeStore {
44 class Database;
45 class DatabaseShard;
46 } // namespace NodeStore
47 namespace perf {
48 class PerfLog;
49 }
50 namespace RPC {
52 }
53 
54 // VFALCO TODO Fix forward declares required for header dependency loops
55 class AmendmentTable;
56 
57 template <
58  class Key,
59  class T,
60  bool IsKeyCache,
61  class Hash,
62  class KeyEqual,
63  class Mutex>
65 class STLedgerEntry;
68 
69 class CollectorManager;
70 class Family;
71 class HashRouter;
72 class Logs;
73 class LoadFeeTrack;
74 class JobQueue;
75 class InboundLedgers;
77 class AcceptedLedger;
78 class Ledger;
79 class LedgerMaster;
80 class LedgerCleaner;
81 class LedgerReplayer;
82 class LoadManager;
83 class ManifestCache;
84 class ValidatorKeys;
85 class NetworkOPs;
86 class OpenLedger;
87 class OrderBookDB;
88 class Overlay;
89 class PathRequests;
90 class PendingSaves;
91 class PublicKey;
92 class SecretKey;
93 class STLedgerEntry;
94 class TimeKeeper;
95 class TransactionMaster;
96 class TxQ;
97 
98 class ValidatorList;
99 class ValidatorSite;
100 class Cluster;
101 
102 class RelationalDatabase;
103 class DatabaseCon;
104 class SHAMapStore;
105 
106 class ReportingETL;
107 
109 
110 template <class Adaptor>
114 
116 {
117 public:
118  /* VFALCO NOTE
119 
120  The master mutex protects:
121 
122  - The open ledger
123  - Server global state
124  * What the last closed ledger is
125  * State of the consensus engine
126 
127  other things
128  */
130  virtual MutexType&
131  getMasterMutex() = 0;
132 
133 public:
134  Application();
135 
136  virtual ~Application() = default;
137 
138  virtual bool
139  setup(boost::program_options::variables_map const& options) = 0;
140 
141  virtual void
142  start(bool withTimers) = 0;
143  virtual void
144  run() = 0;
145  virtual void
146  signalStop(std::string msg = "") = 0;
147  virtual bool
148  checkSigs() const = 0;
149  virtual void
150  checkSigs(bool) = 0;
151  virtual bool
152  isStopping() const = 0;
153 
154  //
155  // ---
156  //
157 
159  virtual std::uint64_t
160  instanceID() const = 0;
161 
162  virtual Logs&
163  logs() = 0;
164  virtual Config&
165  config() = 0;
166 
167  virtual boost::asio::io_service&
168  getIOService() = 0;
169 
170  virtual CollectorManager&
171  getCollectorManager() = 0;
172  virtual Family&
173  getNodeFamily() = 0;
174  virtual Family*
175  getShardFamily() = 0;
176  virtual TimeKeeper&
177  timeKeeper() = 0;
178  virtual JobQueue&
179  getJobQueue() = 0;
180  virtual NodeCache&
181  getTempNodeCache() = 0;
182  virtual CachedSLEs&
183  cachedSLEs() = 0;
184  virtual AmendmentTable&
185  getAmendmentTable() = 0;
186  virtual HashRouter&
187  getHashRouter() = 0;
188  virtual LoadFeeTrack&
189  getFeeTrack() = 0;
190  virtual LoadManager&
191  getLoadManager() = 0;
192  virtual Overlay&
193  overlay() = 0;
194  virtual TxQ&
195  getTxQ() = 0;
196  virtual ValidatorList&
197  validators() = 0;
198  virtual ValidatorSite&
199  validatorSites() = 0;
200  virtual ManifestCache&
201  validatorManifests() = 0;
202  virtual ManifestCache&
203  publisherManifests() = 0;
204  virtual Cluster&
205  cluster() = 0;
206  virtual PeerReservationTable&
207  peerReservations() = 0;
208  virtual RCLValidations&
209  getValidations() = 0;
210  virtual NodeStore::Database&
211  getNodeStore() = 0;
212  virtual NodeStore::DatabaseShard*
213  getShardStore() = 0;
214  virtual RPC::ShardArchiveHandler*
215  getShardArchiveHandler(bool tryRecovery = false) = 0;
216  virtual InboundLedgers&
217  getInboundLedgers() = 0;
218  virtual InboundTransactions&
220 
223 
224  virtual LedgerMaster&
225  getLedgerMaster() = 0;
226  virtual LedgerCleaner&
227  getLedgerCleaner() = 0;
228  virtual LedgerReplayer&
229  getLedgerReplayer() = 0;
230  virtual NetworkOPs&
231  getOPs() = 0;
232  virtual OrderBookDB&
233  getOrderBookDB() = 0;
234  virtual TransactionMaster&
235  getMasterTransaction() = 0;
236  virtual perf::PerfLog&
237  getPerfLog() = 0;
238 
239  virtual std::pair<PublicKey, SecretKey> const&
240  nodeIdentity() = 0;
241 
242  virtual PublicKey const&
243  getValidationPublicKey() const = 0;
244 
245  virtual Resource::Manager&
246  getResourceManager() = 0;
247  virtual PathRequests&
248  getPathRequests() = 0;
249  virtual SHAMapStore&
250  getSHAMapStore() = 0;
251  virtual PendingSaves&
252  pendingSaves() = 0;
253  virtual OpenLedger&
254  openLedger() = 0;
255  virtual OpenLedger const&
256  openLedger() const = 0;
257  virtual RelationalDatabase&
258  getRelationalDatabase() = 0;
259 
261  getIOLatency() = 0;
262 
263  virtual ReportingETL&
264  getReportingETL() = 0;
265 
266  virtual bool
267  serverOkay(std::string& reason) = 0;
268 
269  virtual beast::Journal
270  journal(std::string const& name) = 0;
271 
272  /* Returns the number of file descriptors the application needs */
273  virtual int
274  fdRequired() const = 0;
275 
277  virtual DatabaseCon&
278  getWalletDB() = 0;
279 
282  virtual LedgerIndex
284 };
285 
290  std::unique_ptr<TimeKeeper> timeKeeper);
291 
292 } // namespace ripple
293 
294 #endif
beast::PropertyStream::Source::name
std::string const & name() const
Returns the name of this source.
Definition: beast_PropertyStream.cpp:190
ripple::NetworkOPs
Provides server functionality for clients.
Definition: NetworkOPs.h:86
ripple::Application::setup
virtual bool setup(boost::program_options::variables_map const &options)=0
ripple::RCLValidationsAdaptor
Generic validations adaptor class for RCL.
Definition: RCLValidations.h:205
ripple::Application
Definition: Application.h:115
ripple::Application::checkSigs
virtual bool checkSigs() const =0
ripple::Application::getNodeFamily
virtual Family & getNodeFamily()=0
ripple::Application::getOrderBookDB
virtual OrderBookDB & getOrderBookDB()=0
ripple::AcceptedLedger
A ledger that has become irrevocable.
Definition: AcceptedLedger.h:44
ripple::Application::getTempNodeCache
virtual NodeCache & getTempNodeCache()=0
ripple::LoadManager
Manages load sources.
Definition: LoadManager.h:45
ripple::Application::cluster
virtual Cluster & cluster()=0
ripple::Application::start
virtual void start(bool withTimers)=0
ripple::Application::getAcceptedLedgerCache
virtual TaggedCache< uint256, AcceptedLedger > & getAcceptedLedgerCache()=0
ripple::STLedgerEntry
Definition: STLedgerEntry.h:30
ripple::NodeStore::Database
Persistency layer for NodeObject.
Definition: Database.h:51
std::string
STL class.
ripple::TaggedCache
Map/cache combination.
Definition: Application.h:64
ripple::Logs
Manages partitions for logging.
Definition: Log.h:48
ripple::TransactionMaster
Definition: TransactionMaster.h:36
ripple::ValidatorSite
Definition: ValidatorSite.h:69
std::pair
ripple::Application::validatorSites
virtual ValidatorSite & validatorSites()=0
beast::PropertyStream::Source
Subclasses can be called to write to a stream and have children.
Definition: PropertyStream.h:330
ripple::LedgerMaster
Definition: LedgerMaster.h:70
ripple::Application::getAmendmentTable
virtual AmendmentTable & getAmendmentTable()=0
ripple::Application::instanceID
virtual std::uint64_t instanceID() const =0
Returns a 64-bit instance identifier, generated at startup.
ripple::Application::peerReservations
virtual PeerReservationTable & peerReservations()=0
ripple::CollectorManager
Provides the beast::insight::Collector service.
Definition: CollectorManager.h:29
std::chrono::milliseconds
ripple::SHAMapStore
class to create database, launch online delete thread, and related SQLite database
Definition: SHAMapStore.h:36
ripple::Application::signalStop
virtual void signalStop(std::string msg="")=0
std::recursive_mutex
STL class.
ripple::Application::getShardStore
virtual NodeStore::DatabaseShard * getShardStore()=0
ripple::perf::PerfLog
Singleton class that maintains performance counters and optionally writes Json-formatted data to a di...
Definition: PerfLog.h:48
ripple::PendingSaves
Keeps track of which ledgers haven't been fully saved.
Definition: PendingSaves.h:36
ripple::Application::isStopping
virtual bool isStopping() const =0
ripple::Application::timeKeeper
virtual TimeKeeper & timeKeeper()=0
ripple::Application::getMasterMutex
virtual MutexType & getMasterMutex()=0
ripple::Application::openLedger
virtual OpenLedger & openLedger()=0
ripple::Application::getOPs
virtual NetworkOPs & getOPs()=0
ripple::Application::cachedSLEs
virtual CachedSLEs & cachedSLEs()=0
ripple::Application::getWalletDB
virtual DatabaseCon & getWalletDB()=0
Retrieve the "wallet database".
ripple::ValidatorKeys
Validator keys and manifest as set in configuration file.
Definition: ValidatorKeys.h:36
ripple::HashRouter
Routing table for objects identified by hash.
Definition: HashRouter.h:53
ripple::Application::getInboundLedgers
virtual InboundLedgers & getInboundLedgers()=0
ripple::Application::getFeeTrack
virtual LoadFeeTrack & getFeeTrack()=0
ripple::Application::getReportingETL
virtual ReportingETL & getReportingETL()=0
ripple::Application::serverOkay
virtual bool serverOkay(std::string &reason)=0
ripple::Application::~Application
virtual ~Application()=default
ripple::TxQ
Transaction Queue.
Definition: TxQ.h:57
ripple::Application::getIOLatency
virtual std::chrono::milliseconds getIOLatency()=0
ripple::Application::getLoadManager
virtual LoadManager & getLoadManager()=0
ripple::Application::getInboundTransactions
virtual InboundTransactions & getInboundTransactions()=0
ripple::Ledger
Holds a ledger.
Definition: Ledger.h:76
ripple::Application::getLedgerMaster
virtual LedgerMaster & getLedgerMaster()=0
ripple::PublicKey
A public key.
Definition: PublicKey.h:59
ripple::Config
Definition: Config.h:89
ripple::Application::pendingSaves
virtual PendingSaves & pendingSaves()=0
ripple::Cluster
Definition: Cluster.h:38
ripple::ValidatorList
Definition: ValidatorList.h:172
ripple::Application::config
virtual Config & config()=0
ripple::Application::getRelationalDatabase
virtual RelationalDatabase & getRelationalDatabase()=0
ripple::Application::nodeIdentity
virtual std::pair< PublicKey, SecretKey > const & nodeIdentity()=0
ripple::NodeStore::DatabaseShard
A collection of historical shards.
Definition: DatabaseShard.h:37
ripple::Application::getTxQ
virtual TxQ & getTxQ()=0
ripple::LoadFeeTrack
Manages the current fee schedule.
Definition: LoadFeeTrack.h:44
ripple::Application::getJobQueue
virtual JobQueue & getJobQueue()=0
ripple::Application::logs
virtual Logs & logs()=0
ripple::ReportingETL
This class is responsible for continuously extracting data from a p2p node, and writing that data to ...
Definition: ReportingETL.h:70
ripple::Family
Definition: Family.h:32
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
ripple::Application::getValidations
virtual RCLValidations & getValidations()=0
std::uint64_t
ripple::SecretKey
A secret key.
Definition: SecretKey.h:36
ripple::TimeKeeper
Manages various times used by the server.
Definition: TimeKeeper.h:32
ripple::Application::getPathRequests
virtual PathRequests & getPathRequests()=0
ripple::Application::getValidationPublicKey
virtual PublicKey const & getValidationPublicKey() const =0
ripple::OrderBookDB
Definition: OrderBookDB.h:30
memory
ripple::InboundLedgers
Manages the lifetime of inbound ledgers.
Definition: InboundLedgers.h:33
ripple::OpenLedger
Represents the open ledger.
Definition: OpenLedger.h:49
ripple::Application::validators
virtual ValidatorList & validators()=0
ripple::Application::getIOService
virtual boost::asio::io_service & getIOService()=0
ripple::JobQueue
A pool of threads to perform work.
Definition: JobQueue.h:55
ripple::Application::Application
Application()
Definition: Application.cpp:2174
ripple::Resource::Manager
Tracks load and resource consumption.
Definition: ResourceManager.h:36
ripple::Application::getResourceManager
virtual Resource::Manager & getResourceManager()=0
ripple::PeerReservationTable
Definition: PeerReservationTable.h:79
ripple::ManifestCache
Remembers manifests with the highest sequence number.
Definition: Manifest.h:231
ripple::Application::getLedgerCleaner
virtual LedgerCleaner & getLedgerCleaner()=0
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::Application::getNodeStore
virtual NodeStore::Database & getNodeStore()=0
ripple::Application::journal
virtual beast::Journal journal(std::string const &name)=0
ripple::Application::validatorManifests
virtual ManifestCache & validatorManifests()=0
ripple::Application::getShardFamily
virtual Family * getShardFamily()=0
ripple::Overlay
Manages the set of connected peers.
Definition: Overlay.h:51
ripple::DatabaseCon
Definition: DatabaseCon.h:81
ripple::Application::publisherManifests
virtual ManifestCache & publisherManifests()=0
ripple::Application::overlay
virtual Overlay & overlay()=0
ripple::RPC::ShardArchiveHandler
Handles the download and import of one or more shard archives.
Definition: ShardArchiveHandler.h:42
ripple::LedgerReplayer
Manages the lifetime of ledger replay tasks.
Definition: LedgerReplayer.h:72
ripple::Validations
Maintains current and recent ledger validations.
Definition: Application.h:111
mutex
ripple::Application::getLedgerReplayer
virtual LedgerReplayer & getLedgerReplayer()=0
ripple::PathRequests
Definition: PathRequests.h:33
ripple::KeyEqual
Definition: PeerReservationTable.h:70
ripple::Application::getSHAMapStore
virtual SHAMapStore & getSHAMapStore()=0
ripple::Application::getCollectorManager
virtual CollectorManager & getCollectorManager()=0
ripple::Application::getPerfLog
virtual perf::PerfLog & getPerfLog()=0
ripple::LedgerCleaner
Check the ledger/transaction databases to make sure they have continuity.
Definition: LedgerCleaner.h:32
ripple::RelationalDatabase
Definition: RelationalDatabase.h:48
ripple::AmendmentTable
The amendment table stores the list of enabled and potential amendments.
Definition: AmendmentTable.h:37
std::unique_ptr
STL class.
ripple::Application::getHashRouter
virtual HashRouter & getHashRouter()=0
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:2181
ripple::Application::fdRequired
virtual int fdRequired() const =0
ripple::Application::run
virtual void run()=0
ripple::Application::getMaxDisallowedLedger
virtual LedgerIndex getMaxDisallowedLedger()=0
Ensure that a newly-started validator does not sign proposals older than the last ledger it persisted...
ripple::Application::getShardArchiveHandler
virtual RPC::ShardArchiveHandler * getShardArchiveHandler(bool tryRecovery=false)=0
ripple::InboundTransactions
Manages the acquisition and lifetime of transaction sets.
Definition: InboundTransactions.h:35
ripple::Application::getMasterTransaction
virtual TransactionMaster & getMasterTransaction()=0