hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
application.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_APPLICATION_HPP
7 #define IROHA_APPLICATION_HPP
8 
12 #include "cryptography/keypair.hpp"
15 #include "logger/logger_fwd.hpp"
20 #include "main/server_runner.hpp"
22 #include "torii/tls_params.hpp"
23 
24 namespace iroha {
25  class PendingTransactionStorage;
26  class PendingTransactionStorageInit;
27  class MstProcessor;
28  namespace ametsuchi {
29  class WsvRestorer;
30  class TxPresenceCache;
31  class Storage;
32  class ReconnectionStrategyFactory;
33  class PostgresOptions;
34  struct PoolWrapper;
35  } // namespace ametsuchi
36  namespace consensus {
37  namespace yac {
38  class YacInit;
39  } // namespace yac
40  } // namespace consensus
41  namespace network {
42  class BlockLoader;
43  class ConsensusGate;
44  class MstTransport;
45  class OrderingGate;
46  class PeerCommunicationService;
47  class PeerTlsCertificatesProvider;
48  struct TlsCredentials;
49  } // namespace network
50  namespace simulator {
51  class Simulator;
52  }
53  namespace synchronizer {
54  class Synchronizer;
55  }
56  namespace torii {
57  class QueryProcessor;
58  class StatusBus;
59  class CommandService;
61  class QueryService;
62 
63  struct TlsParams;
64  } // namespace torii
65  namespace validation {
66  class ChainValidator;
67  class StatefulValidator;
68  } // namespace validation
69 } // namespace iroha
70 
71 namespace shared_model {
72  namespace crypto {
73  class Keypair;
74  }
75  namespace interface {
76  class QueryResponseFactory;
77  class TransactionBatchFactory;
78  } // namespace interface
79 } // namespace shared_model
80 
81 class Irohad {
82  public:
84 
113  Irohad(const boost::optional<std::string> &block_store_dir,
114  std::unique_ptr<iroha::ametsuchi::PostgresOptions> pg_opt,
115  const std::string &listen_ip,
116  size_t torii_port,
117  size_t internal_port,
118  size_t max_proposal_size,
119  std::chrono::milliseconds proposal_delay,
120  std::chrono::milliseconds vote_delay,
121  std::chrono::minutes mst_expiration_time,
122  const shared_model::crypto::Keypair &keypair,
123  std::chrono::milliseconds max_rounds_delay,
124  size_t stale_stream_max_rounds,
125  boost::optional<shared_model::interface::types::PeerList>
126  opt_alternative_peers,
127  logger::LoggerManagerTreePtr logger_manager,
128  const boost::optional<iroha::GossipPropagationStrategyParams>
129  &opt_mst_gossip_params = boost::none,
130  const boost::optional<iroha::torii::TlsParams> &torii_tls_params =
131  boost::none,
132  boost::optional<IrohadConfig::InterPeerTls> inter_peer_tls_config =
133  boost::none);
134 
138  virtual RunResult init();
139 
144  RunResult restoreWsv();
145 
149  RunResult validateKeypair();
150 
154  virtual void dropStorage();
155 
160  RunResult run();
161 
162  virtual ~Irohad();
163 
164  protected:
165  // -----------------------| component initialization |------------------------
166  virtual RunResult initStorage(
167  std::unique_ptr<iroha::ametsuchi::PostgresOptions> pg_opt);
168 
169  RunResult initTlsCredentials();
170 
171  RunResult initPeerCertProvider();
172 
173  virtual RunResult initCryptoProvider();
174 
175  virtual RunResult initBatchParser();
176 
177  virtual RunResult initValidators();
178 
179  virtual RunResult initNetworkClient();
180 
181  virtual RunResult initFactories();
182 
183  virtual RunResult initPersistentCache();
184 
185  virtual RunResult initOrderingGate();
186 
187  virtual RunResult initSimulator();
188 
189  virtual RunResult initConsensusCache();
190 
191  virtual RunResult initBlockLoader();
192 
193  virtual RunResult initConsensusGate();
194 
195  virtual RunResult initSynchronizer();
196 
197  virtual RunResult initPeerCommunicationService();
198 
199  virtual RunResult initStatusBus();
200 
201  virtual RunResult initMstProcessor();
202 
203  virtual RunResult initPendingTxsStorage();
204 
205  virtual RunResult initTransactionCommandService();
206 
207  virtual RunResult initQueryService();
208 
209  virtual RunResult initSettings();
210 
211  virtual RunResult initValidatorsConfigs();
212 
216  virtual RunResult initWsvRestorer();
217 
218  // constructor dependencies
219  const boost::optional<std::string> block_store_dir_;
220  const std::string listen_ip_;
221  size_t torii_port_;
222  boost::optional<iroha::torii::TlsParams> torii_tls_params_;
225  std::chrono::milliseconds proposal_delay_;
226  std::chrono::milliseconds vote_delay_;
228  std::chrono::minutes mst_expiration_time_;
229  std::chrono::milliseconds max_rounds_delay_;
231  const boost::optional<shared_model::interface::types::PeerList>
233  boost::optional<iroha::GossipPropagationStrategyParams>
235  boost::optional<IrohadConfig::InterPeerTls> inter_peer_tls_config_;
236 
237  boost::optional<std::shared_ptr<const iroha::network::TlsCredentials>>
239  boost::optional<std::shared_ptr<const iroha::network::TlsCredentials>>
241  boost::optional<
242  std::shared_ptr<const iroha::network::PeerTlsCertificatesProvider>>
244 
245  std::unique_ptr<iroha::PendingTransactionStorageInit>
247 
248  // pending transactions storage
249  std::shared_ptr<iroha::PendingTransactionStorage> pending_txs_storage_;
250 
251  // query response factory
252  std::shared_ptr<shared_model::interface::QueryResponseFactory>
254 
255  // ------------------------| internal dependencies |-------------------------
256  public:
258  std::shared_ptr<iroha::ametsuchi::Storage> storage;
259 
260  protected:
261  // initialization objects
263  std::unique_ptr<iroha::consensus::yac::YacInit> yac_init;
265 
266  std::shared_ptr<iroha::ametsuchi::PoolWrapper> pool_wrapper_;
267 
268  // Settings
269  std::shared_ptr<const shared_model::validation::Settings> settings_;
270 
271  // WSV restorer
272  std::shared_ptr<iroha::ametsuchi::WsvRestorer> wsv_restorer_;
273 
274  // crypto provider
278 
279  // batch parser
280  std::shared_ptr<shared_model::interface::TransactionBatchParser> batch_parser;
281 
282  // validators
283  std::shared_ptr<shared_model::validation::ValidatorsConfig>
285  std::shared_ptr<shared_model::validation::ValidatorsConfig>
287  std::shared_ptr<shared_model::validation::ValidatorsConfig>
289  std::shared_ptr<iroha::validation::StatefulValidator> stateful_validator;
290  std::shared_ptr<iroha::validation::ChainValidator> chain_validator;
291 
292  // async call
293  std::shared_ptr<iroha::network::AsyncGrpcClient<google::protobuf::Empty>>
295 
296  // transaction batch factory
297  std::shared_ptr<shared_model::interface::TransactionBatchFactory>
299 
300  // transaction factory
305 
306  // query factory
311 
312  // blocks query factory
315  iroha::protocol::BlocksQuery>>
317 
318  // persistent cache
319  std::shared_ptr<iroha::ametsuchi::TxPresenceCache> persistent_cache;
320 
321  // proposal factory
324  iroha::protocol::Proposal>>
326 
327  // ordering gate
328  std::shared_ptr<iroha::network::OrderingGate> ordering_gate;
329 
330  // simulator
331  std::shared_ptr<iroha::simulator::Simulator> simulator;
332 
333  // block cache for consensus and block loader
334  std::shared_ptr<iroha::consensus::ConsensusResultCache>
336 
337  // block loader
338  std::shared_ptr<iroha::network::BlockLoader> block_loader;
339 
340  // synchronizer
341  std::shared_ptr<iroha::synchronizer::Synchronizer> synchronizer;
342 
343  // pcs
344  std::shared_ptr<iroha::network::PeerCommunicationService> pcs;
345 
346  // status bus
347  std::shared_ptr<iroha::torii::StatusBus> status_bus_;
348 
349  // mst
350  std::shared_ptr<iroha::network::MstTransport> mst_transport;
351  std::shared_ptr<iroha::MstProcessor> mst_processor;
352 
353  // transaction service
354  std::shared_ptr<iroha::torii::CommandService> command_service;
355  std::shared_ptr<iroha::torii::CommandServiceTransportGrpc>
357 
358  // query service
359  std::shared_ptr<iroha::torii::QueryService> query_service;
360 
361  // consensus gate
362  std::shared_ptr<iroha::network::ConsensusGate> consensus_gate;
363  rxcpp::composite_subscription consensus_gate_objects_lifetime;
364  rxcpp::subjects::subject<iroha::consensus::GateObject> consensus_gate_objects;
365  rxcpp::composite_subscription consensus_gate_events_subscription;
366 
367  std::unique_ptr<iroha::network::ServerRunner> torii_server;
368  boost::optional<std::unique_ptr<iroha::network::ServerRunner>>
369  torii_tls_server = boost::none;
370  std::unique_ptr<iroha::network::ServerRunner> internal_server;
371 
373 
375 };
376 
377 #endif // IROHA_APPLICATION_HPP
std::shared_ptr< iroha::torii::StatusBus > status_bus_
Definition: application.hpp:347
std::shared_ptr< iroha::ametsuchi::PoolWrapper > pool_wrapper_
Definition: application.hpp:266
std::shared_ptr< shared_model::crypto::AbstractCryptoModelSigner< shared_model::interface::Block > > crypto_signer_
Definition: application.hpp:277
iroha::network::BlockLoaderInit loader_init
Definition: application.hpp:264
std::shared_ptr< iroha::torii::CommandServiceTransportGrpc > command_service_transport
Definition: application.hpp:356
std::shared_ptr< iroha::PendingTransactionStorage > pending_txs_storage_
Definition: application.hpp:249
Definition: command_client.hpp:16
bool is_mst_supported_
Definition: application.hpp:227
Definition: query.hpp:35
std::shared_ptr< iroha::validation::StatefulValidator > stateful_validator
Definition: application.hpp:289
std::shared_ptr< iroha::network::AsyncGrpcClient< google::protobuf::Empty > > async_call_
Definition: application.hpp:294
std::chrono::minutes mst_expiration_time_
Definition: application.hpp:228
Definition: block_loader_init.hpp:22
Definition: synchronizer.hpp:19
Definition: blocks_query.hpp:20
Definition: keypair.hpp:19
std::shared_ptr< iroha::ametsuchi::Storage > storage
Definition: application.hpp:258
Definition: result_fwd.hpp:27
logger::LoggerManagerTreePtr log_manager_
application root log manager
Definition: application.hpp:372
size_t internal_port_
Definition: application.hpp:223
Definition: proposal.hpp:17
std::shared_ptr< shared_model::interface::AbstractTransportFactory< shared_model::interface::Query, iroha::protocol::Query > > query_factory
Definition: application.hpp:310
const boost::optional< shared_model::interface::types::PeerList > opt_alternative_peers_
Definition: application.hpp:232
boost::optional< std::shared_ptr< const iroha::network::TlsCredentials > > my_inter_peer_tls_creds_
Definition: application.hpp:238
std::shared_ptr< iroha::network::PeerCommunicationService > pcs
Definition: application.hpp:344
rxcpp::composite_subscription consensus_gate_events_subscription
Definition: application.hpp:365
std::shared_ptr< shared_model::interface::AbstractTransportFactory< shared_model::interface::Transaction, iroha::protocol::Transaction > > transaction_factory
Definition: application.hpp:304
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
std::shared_ptr< iroha::MstProcessor > mst_processor
Definition: application.hpp:351
std::shared_ptr< iroha::ametsuchi::WsvRestorer > wsv_restorer_
Definition: application.hpp:272
std::shared_ptr< shared_model::interface::TransactionBatchParser > batch_parser
Definition: application.hpp:280
size_t stale_stream_max_rounds_
Definition: application.hpp:230
std::shared_ptr< iroha::network::ConsensusGate > consensus_gate
Definition: application.hpp:362
Definition: stateful_validator.hpp:19
std::chrono::milliseconds proposal_delay_
Definition: application.hpp:225
Definition: block.hpp:16
boost::optional< std::shared_ptr< const iroha::network::TlsCredentials > > torii_tls_creds_
Definition: application.hpp:240
std::chrono::milliseconds max_rounds_delay_
Definition: application.hpp:229
std::shared_ptr< shared_model::validation::ValidatorsConfig > validators_config_
Definition: application.hpp:284
Definition: chain_validator.hpp:30
std::shared_ptr< iroha::consensus::ConsensusResultCache > consensus_result_cache_
Definition: application.hpp:335
std::shared_ptr< const shared_model::validation::Settings > settings_
Definition: application.hpp:269
std::unique_ptr< iroha::consensus::yac::YacInit > yac_init
Definition: application.hpp:263
std::shared_ptr< iroha::ametsuchi::TxPresenceCache > persistent_cache
Definition: application.hpp:319
Definition: block_query.hpp:14
iroha::network::OnDemandOrderingInit ordering_init
Definition: application.hpp:262
std::chrono::milliseconds vote_delay_
Definition: application.hpp:226
const boost::optional< std::string > block_store_dir_
Definition: application.hpp:219
std::shared_ptr< iroha::validation::ChainValidator > chain_validator
Definition: application.hpp:290
Definition: query_service.hpp:35
Definition: application.hpp:81
std::shared_ptr< LoggerManagerTree > LoggerManagerTreePtr
Definition: logger_manager_fwd.hpp:14
std::shared_ptr< iroha::network::OrderingGate > ordering_gate
Definition: application.hpp:328
std::shared_ptr< shared_model::interface::AbstractTransportFactory< shared_model::interface::Proposal, iroha::protocol::Proposal > > proposal_factory
Definition: application.hpp:325
logger::LoggerPtr log_
log for local messages
Definition: application.hpp:374
std::shared_ptr< shared_model::validation::ValidatorsConfig > block_validators_config_
Definition: application.hpp:288
Definition: on_demand_ordering_init.hpp:32
std::shared_ptr< iroha::simulator::Simulator > simulator
Definition: application.hpp:331
boost::optional< iroha::GossipPropagationStrategyParams > opt_mst_gossip_params_
Definition: application.hpp:234
rxcpp::composite_subscription consensus_gate_objects_lifetime
Definition: application.hpp:363
rxcpp::subjects::subject< iroha::consensus::GateObject > consensus_gate_objects
Definition: application.hpp:364
std::shared_ptr< shared_model::interface::TransactionBatchFactory > transaction_batch_factory_
Definition: application.hpp:298
boost::optional< std::shared_ptr< const iroha::network::PeerTlsCertificatesProvider > > peer_tls_certificates_provider_
Definition: application.hpp:243
std::unique_ptr< iroha::network::ServerRunner > torii_server
Definition: application.hpp:367
Definition: status_bus.hpp:17
Definition: command_service.hpp:26
std::unique_ptr< iroha::network::ServerRunner > internal_server
Definition: application.hpp:370
shared_model::crypto::Keypair keypair
Definition: application.hpp:257
std::shared_ptr< iroha::torii::CommandService > command_service
Definition: application.hpp:354
std::shared_ptr< shared_model::interface::AbstractTransportFactory< shared_model::interface::BlocksQuery, iroha::protocol::BlocksQuery > > blocks_query_factory
Definition: application.hpp:316
std::shared_ptr< iroha::synchronizer::Synchronizer > synchronizer
Definition: application.hpp:341
size_t torii_port_
Definition: application.hpp:221
Definition: command_executor.hpp:12
const std::string listen_ip_
Definition: application.hpp:220
std::shared_ptr< iroha::torii::QueryService > query_service
Definition: application.hpp:359
Definition: transaction.hpp:23
std::shared_ptr< shared_model::interface::QueryResponseFactory > query_response_factory_
Definition: application.hpp:253
Definition: tls_params.hpp:23
Definition: command_service_transport_grpc.hpp:34
std::shared_ptr< shared_model::validation::ValidatorsConfig > proposal_validators_config_
Definition: application.hpp:286
size_t max_proposal_size_
Definition: application.hpp:224
std::unique_ptr< iroha::PendingTransactionStorageInit > pending_txs_storage_init
Definition: application.hpp:246
Definition: query_processor.hpp:28
boost::optional< IrohadConfig::InterPeerTls > inter_peer_tls_config_
Definition: application.hpp:235
std::shared_ptr< iroha::network::BlockLoader > block_loader
Definition: application.hpp:338
boost::optional< iroha::torii::TlsParams > torii_tls_params_
Definition: application.hpp:222
std::shared_ptr< iroha::network::MstTransport > mst_transport
Definition: application.hpp:350
Definition: abstract_crypto_model_signer.hpp:16