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 <memory>
32 #include <mutex>
33 
34 namespace ripple {
35 
36 namespace unl {
37 class Manager;
38 }
39 namespace Resource {
40 class Manager;
41 }
42 namespace NodeStore {
43 class Database;
44 class DatabaseShard;
45 } // namespace NodeStore
46 namespace perf {
47 class PerfLog;
48 }
49 namespace RPC {
51 }
52 
53 // VFALCO TODO Fix forward declares required for header dependency loops
54 class AmendmentTable;
55 class CachedSLEs;
56 class CollectorManager;
57 class Family;
58 class HashRouter;
59 class Logs;
60 class LoadFeeTrack;
61 class JobQueue;
62 class InboundLedgers;
64 class AcceptedLedger;
65 class Ledger;
66 class LedgerMaster;
67 class LedgerReplayer;
68 class LoadManager;
69 class ManifestCache;
70 class ValidatorKeys;
71 class NetworkOPs;
72 class OpenLedger;
73 class OrderBookDB;
74 class Overlay;
75 class PathRequests;
76 class PendingSaves;
77 class PgPool;
78 class PublicKey;
79 class SecretKey;
80 class AccountIDCache;
81 class STLedgerEntry;
82 class TimeKeeper;
83 class TransactionMaster;
84 class TxQ;
85 
86 class ValidatorList;
87 class ValidatorSite;
88 class Cluster;
89 
90 class DatabaseCon;
91 class SHAMapStore;
92 
93 class ReportingETL;
94 
96 
97 template <class Adaptor>
101 
103 {
104 public:
105  /* VFALCO NOTE
106 
107  The master mutex protects:
108 
109  - The open ledger
110  - Server global state
111  * What the last closed ledger is
112  * State of the consensus engine
113 
114  other things
115  */
117  virtual MutexType&
118  getMasterMutex() = 0;
119 
120 public:
121  Application();
122 
123  virtual ~Application() = default;
124 
125  virtual bool
126  setup() = 0;
127  virtual void
128  doStart(bool withTimers) = 0;
129  virtual void
130  run() = 0;
131  virtual bool
132  isShutdown() = 0;
133  virtual void
134  signalStop() = 0;
135  virtual bool
136  checkSigs() const = 0;
137  virtual void
138  checkSigs(bool) = 0;
139 
140  //
141  // ---
142  //
143 
144  virtual Logs&
145  logs() = 0;
146  virtual Config&
147  config() = 0;
148 
149  virtual boost::asio::io_service&
150  getIOService() = 0;
151 
152  virtual CollectorManager&
153  getCollectorManager() = 0;
154  virtual Family&
155  getNodeFamily() = 0;
156  virtual Family*
157  getShardFamily() = 0;
158  virtual TimeKeeper&
159  timeKeeper() = 0;
160  virtual JobQueue&
161  getJobQueue() = 0;
162  virtual NodeCache&
163  getTempNodeCache() = 0;
164  virtual CachedSLEs&
165  cachedSLEs() = 0;
166  virtual AmendmentTable&
167  getAmendmentTable() = 0;
168  virtual HashRouter&
169  getHashRouter() = 0;
170  virtual LoadFeeTrack&
171  getFeeTrack() = 0;
172  virtual LoadManager&
173  getLoadManager() = 0;
174  virtual Overlay&
175  overlay() = 0;
176  virtual TxQ&
177  getTxQ() = 0;
178  virtual ValidatorList&
179  validators() = 0;
180  virtual ValidatorSite&
181  validatorSites() = 0;
182  virtual ManifestCache&
183  validatorManifests() = 0;
184  virtual ManifestCache&
185  publisherManifests() = 0;
186  virtual Cluster&
187  cluster() = 0;
188  virtual PeerReservationTable&
189  peerReservations() = 0;
190  virtual RCLValidations&
191  getValidations() = 0;
192  virtual NodeStore::Database&
193  getNodeStore() = 0;
194  virtual NodeStore::DatabaseShard*
195  getShardStore() = 0;
196  virtual RPC::ShardArchiveHandler*
197  getShardArchiveHandler(bool tryRecovery = false) = 0;
198  virtual InboundLedgers&
199  getInboundLedgers() = 0;
200  virtual InboundTransactions&
202 
205 
206  virtual LedgerMaster&
207  getLedgerMaster() = 0;
208  virtual LedgerReplayer&
209  getLedgerReplayer() = 0;
210  virtual NetworkOPs&
211  getOPs() = 0;
212  virtual OrderBookDB&
213  getOrderBookDB() = 0;
214  virtual TransactionMaster&
215  getMasterTransaction() = 0;
216  virtual perf::PerfLog&
217  getPerfLog() = 0;
218 
219  virtual std::pair<PublicKey, SecretKey> const&
220  nodeIdentity() = 0;
221 
222  virtual PublicKey const&
223  getValidationPublicKey() const = 0;
224 
225  virtual Resource::Manager&
226  getResourceManager() = 0;
227  virtual PathRequests&
228  getPathRequests() = 0;
229  virtual SHAMapStore&
230  getSHAMapStore() = 0;
231  virtual PendingSaves&
232  pendingSaves() = 0;
233  virtual AccountIDCache const&
234  accountIDCache() const = 0;
235  virtual OpenLedger&
236  openLedger() = 0;
237  virtual OpenLedger const&
238  openLedger() const = 0;
239  virtual DatabaseCon&
240  getTxnDB() = 0;
241  virtual DatabaseCon&
242  getLedgerDB() = 0;
243 
245  getIOLatency() = 0;
246 
247  virtual ReportingETL&
248  getReportingETL() = 0;
249 
250  virtual bool
251  serverOkay(std::string& reason) = 0;
252 
253 #ifdef RIPPLED_REPORTING
254  virtual std::shared_ptr<PgPool> const&
255  getPgPool() = 0;
256 #endif
257 
258  virtual beast::Journal
259  journal(std::string const& name) = 0;
260 
261  /* Returns the number of file descriptors the application needs */
262  virtual int
263  fdRequired() const = 0;
264 
266  virtual DatabaseCon&
267  getWalletDB() = 0;
268 
271  virtual LedgerIndex
273 };
274 
279  std::unique_ptr<TimeKeeper> timeKeeper);
280 
281 } // namespace ripple
282 
283 #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:88
ripple::RCLValidationsAdaptor
Generic validations adaptor class for RCL.
Definition: RCLValidations.h:205
ripple::Application
Definition: Application.h:102
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:43
ripple::Application::cluster
virtual Cluster & cluster()=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:50
std::string
STL class.
std::shared_ptr
STL class.
ripple::TaggedCache< SHAMapHash, Blob >
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:342
ripple::LedgerMaster
Definition: LedgerMaster.h:72
ripple::Application::getAmendmentTable
virtual AmendmentTable & getAmendmentTable()=0
ripple::Application::isShutdown
virtual bool isShutdown()=0
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:37
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:46
ripple::PendingSaves
Keeps track of which ledgers haven't been fully saved.
Definition: PendingSaves.h:36
ripple::Application::timeKeeper
virtual TimeKeeper & timeKeeper()=0
ripple::Application::getMasterMutex
virtual MutexType & getMasterMutex()=0
ripple::Application::openLedger
virtual OpenLedger & openLedger()=0
ripple::AccountIDCache
Caches the base58 representations of AccountIDs.
Definition: AccountID.h:118
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::Application::accountIDCache
virtual AccountIDCache const & accountIDCache() const =0
ripple::HashRouter
Routing table for objects identified by hash.
Definition: HashRouter.h:52
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:55
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:77
ripple::Application::getLedgerMaster
virtual LedgerMaster & getLedgerMaster()=0
ripple::PublicKey
A public key.
Definition: PublicKey.h:59
ripple::Config
Definition: Config.h:67
ripple::Application::pendingSaves
virtual PendingSaves & pendingSaves()=0
ripple::Cluster
Definition: Cluster.h:38
ripple::CachedSLEs
Caches SLEs by their digest.
Definition: CachedSLEs.h:32
ripple::ValidatorList
Definition: ValidatorList.h:172
ripple::Application::config
virtual Config & config()=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:43
ripple::Application::getJobQueue
virtual JobQueue & getJobQueue()=0
ripple::Application::logs
virtual Logs & logs()=0
ripple::Application::doStart
virtual void doStart(bool withTimers)=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
ripple::Application::getLedgerDB
virtual DatabaseCon & getLedgerDB()=0
std::uint32_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:31
memory
ripple::InboundLedgers
Manages the lifetime of inbound ledgers.
Definition: InboundLedgers.h:34
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:2296
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:209
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:52
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:39
ripple::LedgerReplayer
Manages the lifetime of ledger replay tasks.
Definition: LedgerReplayer.h:73
ripple::Validations
Maintains current and recent ledger validations.
Definition: Application.h:98
mutex
ripple::Application::signalStop
virtual void signalStop()=0
ripple::Application::getLedgerReplayer
virtual LedgerReplayer & getLedgerReplayer()=0
ripple::PathRequests
Definition: PathRequests.h:33
ripple::Application::getSHAMapStore
virtual SHAMapStore & getSHAMapStore()=0
ripple::Application::getCollectorManager
virtual CollectorManager & getCollectorManager()=0
ripple::Application::getPerfLog
virtual perf::PerfLog & getPerfLog()=0
ripple::AmendmentTable
The amendment table stores the list of enabled and potential amendments.
Definition: AmendmentTable.h:34
std::unique_ptr
STL class.
ripple::Application::setup
virtual bool setup()=0
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:2303
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::Application::getTxnDB
virtual DatabaseCon & getTxnDB()=0
ripple::InboundTransactions
Manages the acquisition and lifetime of transaction sets.
Definition: InboundTransactions.h:36
ripple::Application::getMasterTransaction
virtual TransactionMaster & getMasterTransaction()=0