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 ServerHandler;
93 class SecretKey;
94 class STLedgerEntry;
95 class TimeKeeper;
96 class TransactionMaster;
97 class TxQ;
98 
99 class ValidatorList;
100 class ValidatorSite;
101 class Cluster;
102 
103 class RelationalDatabase;
104 class DatabaseCon;
105 class SHAMapStore;
106 
107 class ReportingETL;
108 
110 
111 template <class Adaptor>
115 
117 {
118 public:
119  /* VFALCO NOTE
120 
121  The master mutex protects:
122 
123  - The open ledger
124  - Server global state
125  * What the last closed ledger is
126  * State of the consensus engine
127 
128  other things
129  */
131  virtual MutexType&
132  getMasterMutex() = 0;
133 
134 public:
135  Application();
136 
137  virtual ~Application() = default;
138 
139  virtual bool
140  setup(boost::program_options::variables_map const& options) = 0;
141 
142  virtual void
143  start(bool withTimers) = 0;
144  virtual void
145  run() = 0;
146  virtual void
147  signalStop(std::string msg = "") = 0;
148  virtual bool
149  checkSigs() const = 0;
150  virtual void
151  checkSigs(bool) = 0;
152  virtual bool
153  isStopping() const = 0;
154 
155  //
156  // ---
157  //
158 
160  virtual std::uint64_t
161  instanceID() const = 0;
162 
163  virtual Logs&
164  logs() = 0;
165  virtual Config&
166  config() = 0;
167 
168  virtual boost::asio::io_service&
169  getIOService() = 0;
170 
171  virtual CollectorManager&
172  getCollectorManager() = 0;
173  virtual Family&
174  getNodeFamily() = 0;
175  virtual Family*
176  getShardFamily() = 0;
177  virtual TimeKeeper&
178  timeKeeper() = 0;
179  virtual JobQueue&
180  getJobQueue() = 0;
181  virtual NodeCache&
182  getTempNodeCache() = 0;
183  virtual CachedSLEs&
184  cachedSLEs() = 0;
185  virtual AmendmentTable&
186  getAmendmentTable() = 0;
187  virtual HashRouter&
188  getHashRouter() = 0;
189  virtual LoadFeeTrack&
190  getFeeTrack() = 0;
191  virtual LoadManager&
192  getLoadManager() = 0;
193  virtual Overlay&
194  overlay() = 0;
195  virtual TxQ&
196  getTxQ() = 0;
197  virtual ValidatorList&
198  validators() = 0;
199  virtual ValidatorSite&
200  validatorSites() = 0;
201  virtual ManifestCache&
202  validatorManifests() = 0;
203  virtual ManifestCache&
204  publisherManifests() = 0;
205  virtual Cluster&
206  cluster() = 0;
207  virtual PeerReservationTable&
208  peerReservations() = 0;
209  virtual RCLValidations&
210  getValidations() = 0;
211  virtual NodeStore::Database&
212  getNodeStore() = 0;
213  virtual NodeStore::DatabaseShard*
214  getShardStore() = 0;
215  virtual RPC::ShardArchiveHandler*
216  getShardArchiveHandler(bool tryRecovery = false) = 0;
217  virtual InboundLedgers&
218  getInboundLedgers() = 0;
219  virtual InboundTransactions&
221 
224 
225  virtual LedgerMaster&
226  getLedgerMaster() = 0;
227  virtual LedgerCleaner&
228  getLedgerCleaner() = 0;
229  virtual LedgerReplayer&
230  getLedgerReplayer() = 0;
231  virtual NetworkOPs&
232  getOPs() = 0;
233  virtual OrderBookDB&
234  getOrderBookDB() = 0;
235  virtual ServerHandler&
236  getServerHandler() = 0;
237  virtual TransactionMaster&
238  getMasterTransaction() = 0;
239  virtual perf::PerfLog&
240  getPerfLog() = 0;
241 
242  virtual std::pair<PublicKey, SecretKey> const&
243  nodeIdentity() = 0;
244 
245  virtual PublicKey const&
246  getValidationPublicKey() const = 0;
247 
248  virtual Resource::Manager&
249  getResourceManager() = 0;
250  virtual PathRequests&
251  getPathRequests() = 0;
252  virtual SHAMapStore&
253  getSHAMapStore() = 0;
254  virtual PendingSaves&
255  pendingSaves() = 0;
256  virtual OpenLedger&
257  openLedger() = 0;
258  virtual OpenLedger const&
259  openLedger() const = 0;
260  virtual RelationalDatabase&
261  getRelationalDatabase() = 0;
262 
264  getIOLatency() = 0;
265 
266  virtual ReportingETL&
267  getReportingETL() = 0;
268 
269  virtual bool
270  serverOkay(std::string& reason) = 0;
271 
272  virtual beast::Journal
273  journal(std::string const& name) = 0;
274 
275  /* Returns the number of file descriptors the application needs */
276  virtual int
277  fdRequired() const = 0;
278 
280  virtual DatabaseCon&
281  getWalletDB() = 0;
282 
285  virtual LedgerIndex
287 };
288 
293  std::unique_ptr<TimeKeeper> timeKeeper);
294 
295 } // namespace ripple
296 
297 #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:116
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::ServerHandler
Definition: ServerHandler.h:47
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:2181
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::getServerHandler
virtual ServerHandler & getServerHandler()=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:112
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:2188
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