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 
56 template <
57  class Key,
58  class T,
59  bool IsKeyCache,
60  class Hash,
61  class KeyEqual,
62  class Mutex>
64 class STLedgerEntry;
67 
68 class CollectorManager;
69 class Family;
70 class HashRouter;
71 class Logs;
72 class LoadFeeTrack;
73 class JobQueue;
74 class InboundLedgers;
76 class AcceptedLedger;
77 class Ledger;
78 class LedgerMaster;
79 class LedgerCleaner;
80 class LedgerReplayer;
81 class LoadManager;
82 class ManifestCache;
83 class ValidatorKeys;
84 class NetworkOPs;
85 class OpenLedger;
86 class OrderBookDB;
87 class Overlay;
88 class PathRequests;
89 class PendingSaves;
90 class PublicKey;
91 class SecretKey;
92 class AccountIDCache;
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() = 0;
140  virtual void
141  start(bool withTimers) = 0;
142  virtual void
143  run() = 0;
144  virtual void
145  signalStop() = 0;
146  virtual bool
147  checkSigs() const = 0;
148  virtual void
149  checkSigs(bool) = 0;
150  virtual bool
151  isStopping() const = 0;
152 
153  //
154  // ---
155  //
156 
157  virtual Logs&
158  logs() = 0;
159  virtual Config&
160  config() = 0;
161 
162  virtual boost::asio::io_service&
163  getIOService() = 0;
164 
165  virtual CollectorManager&
166  getCollectorManager() = 0;
167  virtual Family&
168  getNodeFamily() = 0;
169  virtual Family*
170  getShardFamily() = 0;
171  virtual TimeKeeper&
172  timeKeeper() = 0;
173  virtual JobQueue&
174  getJobQueue() = 0;
175  virtual NodeCache&
176  getTempNodeCache() = 0;
177  virtual CachedSLEs&
178  cachedSLEs() = 0;
179  virtual AmendmentTable&
180  getAmendmentTable() = 0;
181  virtual HashRouter&
182  getHashRouter() = 0;
183  virtual LoadFeeTrack&
184  getFeeTrack() = 0;
185  virtual LoadManager&
186  getLoadManager() = 0;
187  virtual Overlay&
188  overlay() = 0;
189  virtual TxQ&
190  getTxQ() = 0;
191  virtual ValidatorList&
192  validators() = 0;
193  virtual ValidatorSite&
194  validatorSites() = 0;
195  virtual ManifestCache&
196  validatorManifests() = 0;
197  virtual ManifestCache&
198  publisherManifests() = 0;
199  virtual Cluster&
200  cluster() = 0;
201  virtual PeerReservationTable&
202  peerReservations() = 0;
203  virtual RCLValidations&
204  getValidations() = 0;
205  virtual NodeStore::Database&
206  getNodeStore() = 0;
207  virtual NodeStore::DatabaseShard*
208  getShardStore() = 0;
209  virtual RPC::ShardArchiveHandler*
210  getShardArchiveHandler(bool tryRecovery = false) = 0;
211  virtual InboundLedgers&
212  getInboundLedgers() = 0;
213  virtual InboundTransactions&
215 
218 
219  virtual LedgerMaster&
220  getLedgerMaster() = 0;
221  virtual LedgerCleaner&
222  getLedgerCleaner() = 0;
223  virtual LedgerReplayer&
224  getLedgerReplayer() = 0;
225  virtual NetworkOPs&
226  getOPs() = 0;
227  virtual OrderBookDB&
228  getOrderBookDB() = 0;
229  virtual TransactionMaster&
230  getMasterTransaction() = 0;
231  virtual perf::PerfLog&
232  getPerfLog() = 0;
233 
234  virtual std::pair<PublicKey, SecretKey> const&
235  nodeIdentity() = 0;
236 
237  virtual PublicKey const&
238  getValidationPublicKey() const = 0;
239 
240  virtual Resource::Manager&
241  getResourceManager() = 0;
242  virtual PathRequests&
243  getPathRequests() = 0;
244  virtual SHAMapStore&
245  getSHAMapStore() = 0;
246  virtual PendingSaves&
247  pendingSaves() = 0;
248  virtual AccountIDCache const&
249  accountIDCache() const = 0;
250  virtual OpenLedger&
251  openLedger() = 0;
252  virtual OpenLedger const&
253  openLedger() const = 0;
254  virtual RelationalDatabase&
255  getRelationalDatabase() = 0;
256 
258  getIOLatency() = 0;
259 
260  virtual ReportingETL&
261  getReportingETL() = 0;
262 
263  virtual bool
264  serverOkay(std::string& reason) = 0;
265 
266  virtual beast::Journal
267  journal(std::string const& name) = 0;
268 
269  /* Returns the number of file descriptors the application needs */
270  virtual int
271  fdRequired() const = 0;
272 
274  virtual DatabaseCon&
275  getWalletDB() = 0;
276 
279  virtual LedgerIndex
281 };
282 
287  std::unique_ptr<TimeKeeper> timeKeeper);
288 
289 } // namespace ripple
290 
291 #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::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:63
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:70
ripple::Application::getAmendmentTable
virtual AmendmentTable & getAmendmentTable()=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:36
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::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: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:68
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::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: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:2148
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:225
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::signalStop
virtual void signalStop()=0
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::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:2155
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