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 
21 namespace iroha {
22  class PendingTransactionStorage;
23  class MstProcessor;
24  namespace ametsuchi {
25  class WsvRestorer;
26  class TxPresenceCache;
27  class Storage;
28  } // namespace ametsuchi
29  namespace consensus {
30  namespace yac {
31  class YacInit;
32  } // namespace yac
33  } // namespace consensus
34  namespace network {
35  class BlockLoader;
36  class ConsensusGate;
37  class PeerCommunicationService;
38  class MstTransport;
39  class OrderingGate;
40  } // namespace network
41  namespace simulator {
42  class Simulator;
43  }
44  namespace synchronizer {
45  class Synchronizer;
46  }
47  namespace torii {
48  class QueryProcessor;
49  class StatusBus;
50  class CommandService;
52  class QueryService;
53  } // namespace torii
54  namespace validation {
55  class ChainValidator;
56  class StatefulValidator;
57  } // namespace validation
58 } // namespace iroha
59 
60 namespace shared_model {
61  namespace crypto {
62  class Keypair;
63  }
64  namespace interface {
65  class CommonObjectsFactory;
66  class QueryResponseFactory;
67  class TransactionBatchFactory;
68  } // namespace interface
69 } // namespace shared_model
70 
71 class ServerRunner;
72 
73 class Irohad {
74  public:
75  using RunResult = iroha::expected::Result<void, std::string>;
76 
101  Irohad(const std::string &block_store_dir,
102  const std::string &pg_conn,
103  const std::string &listen_ip,
104  size_t torii_port,
105  size_t internal_port,
106  size_t max_proposal_size,
107  std::chrono::milliseconds proposal_delay,
108  std::chrono::milliseconds vote_delay,
109  std::chrono::minutes mst_expiration_time,
110  const shared_model::crypto::Keypair &keypair,
111  std::chrono::milliseconds max_rounds_delay,
112  size_t stale_stream_max_rounds,
113  logger::LoggerManagerTreePtr logger_manager,
114  const boost::optional<iroha::GossipPropagationStrategyParams>
115  &opt_mst_gossip_params = boost::none);
116 
120  virtual void init();
121 
126  bool restoreWsv();
127 
131  virtual void dropStorage();
132 
137  RunResult run();
138 
139  virtual ~Irohad();
140 
141  protected:
142  // -----------------------| component initialization |------------------------
143 
144  virtual void initStorage();
145 
146  virtual void initCryptoProvider();
147 
148  virtual void initBatchParser();
149 
150  virtual void initValidators();
151 
152  virtual void initNetworkClient();
153 
154  virtual void initFactories();
155 
156  virtual void initPersistentCache();
157 
158  virtual void initOrderingGate();
159 
160  virtual void initSimulator();
161 
162  virtual void initConsensusCache();
163 
164  virtual void initBlockLoader();
165 
166  virtual void initConsensusGate();
167 
168  virtual void initSynchronizer();
169 
170  virtual void initPeerCommunicationService();
171 
172  virtual void initStatusBus();
173 
174  virtual void initMstProcessor();
175 
176  virtual void initPendingTxsStorage();
177 
178  virtual void initTransactionCommandService();
179 
180  virtual void initQueryService();
181 
185  virtual void initWsvRestorer();
186 
187  // constructor dependencies
188  std::string block_store_dir_;
189  std::string pg_conn_;
190  const std::string listen_ip_;
191  size_t torii_port_;
194  std::chrono::milliseconds proposal_delay_;
195  std::chrono::milliseconds vote_delay_;
197  std::chrono::minutes mst_expiration_time_;
198  std::chrono::milliseconds max_rounds_delay_;
200  boost::optional<iroha::GossipPropagationStrategyParams>
202 
203  // ------------------------| internal dependencies |-------------------------
204  public:
206  std::shared_ptr<iroha::ametsuchi::Storage> storage;
207 
208  protected:
209  // initialization objects
211  std::unique_ptr<iroha::consensus::yac::YacInit> yac_init;
213 
214  // common objects factory
215  std::shared_ptr<shared_model::interface::CommonObjectsFactory>
217 
218  // WSV restorer
219  std::shared_ptr<iroha::ametsuchi::WsvRestorer> wsv_restorer_;
220 
221  // crypto provider
225 
226  // batch parser
227  std::shared_ptr<shared_model::interface::TransactionBatchParser> batch_parser;
228 
229  // validators
230  std::shared_ptr<shared_model::validation::ValidatorsConfig>
232  std::shared_ptr<iroha::validation::StatefulValidator> stateful_validator;
233  std::shared_ptr<iroha::validation::ChainValidator> chain_validator;
234 
235  // async call
236  std::shared_ptr<iroha::network::AsyncGrpcClient<google::protobuf::Empty>>
238 
239  // transaction batch factory
240  std::shared_ptr<shared_model::interface::TransactionBatchFactory>
242 
243  // transaction factory
248 
249  // query response factory
250  std::shared_ptr<shared_model::interface::QueryResponseFactory>
252 
253  // query factory
258 
259  // blocks query factory
262  iroha::protocol::BlocksQuery>>
264 
265  // persistent cache
266  std::shared_ptr<iroha::ametsuchi::TxPresenceCache> persistent_cache;
267 
268  // proposal factory
271  iroha::protocol::Proposal>>
273 
274  // ordering gate
275  std::shared_ptr<iroha::network::OrderingGate> ordering_gate;
276 
277  // simulator
278  std::shared_ptr<iroha::simulator::Simulator> simulator;
279 
280  // block cache for consensus and block loader
281  std::shared_ptr<iroha::consensus::ConsensusResultCache>
283 
284  // block loader
285  std::shared_ptr<iroha::network::BlockLoader> block_loader;
286 
287  // consensus gate
288  std::shared_ptr<iroha::network::ConsensusGate> consensus_gate;
289  rxcpp::composite_subscription consensus_gate_objects_lifetime;
290  rxcpp::subjects::subject<iroha::consensus::GateObject> consensus_gate_objects;
291  rxcpp::composite_subscription consensus_gate_events_subscription;
292 
293  // synchronizer
294  std::shared_ptr<iroha::synchronizer::Synchronizer> synchronizer;
295 
296  // pcs
297  std::shared_ptr<iroha::network::PeerCommunicationService> pcs;
298 
299  // status bus
300  std::shared_ptr<iroha::torii::StatusBus> status_bus_;
301 
302  // mst
303  std::shared_ptr<iroha::network::MstTransport> mst_transport;
304  std::shared_ptr<iroha::MstProcessor> mst_processor;
305 
306  // pending transactions storage
307  std::shared_ptr<iroha::PendingTransactionStorage> pending_txs_storage_;
308 
309  // transaction service
310  std::shared_ptr<iroha::torii::CommandService> command_service;
311  std::shared_ptr<iroha::torii::CommandServiceTransportGrpc>
313 
314  // query service
315  std::shared_ptr<iroha::torii::QueryService> query_service;
316 
317  std::unique_ptr<ServerRunner> torii_server;
318  std::unique_ptr<ServerRunner> internal_server;
319 
321 
323 };
324 
325 #endif // IROHA_APPLICATION_HPP
iroha::expected::Result< void, std::string > RunResult
Definition: application.hpp:75
std::shared_ptr< iroha::torii::StatusBus > status_bus_
Definition: application.hpp:300
std::shared_ptr< shared_model::crypto::AbstractCryptoModelSigner< shared_model::interface::Block > > crypto_signer_
Definition: application.hpp:224
iroha::network::BlockLoaderInit loader_init
Definition: application.hpp:212
std::shared_ptr< iroha::torii::CommandServiceTransportGrpc > command_service_transport
Definition: application.hpp:312
std::shared_ptr< iroha::PendingTransactionStorage > pending_txs_storage_
Definition: application.hpp:307
Definition: command_client.hpp:16
bool is_mst_supported_
Definition: application.hpp:196
Definition: query.hpp:34
std::shared_ptr< iroha::validation::StatefulValidator > stateful_validator
Definition: application.hpp:232
std::string block_store_dir_
Definition: application.hpp:188
std::shared_ptr< iroha::network::AsyncGrpcClient< google::protobuf::Empty > > async_call_
Definition: application.hpp:237
std::chrono::minutes mst_expiration_time_
Definition: application.hpp:197
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:206
logger::LoggerManagerTreePtr log_manager_
application root log manager
Definition: application.hpp:320
size_t internal_port_
Definition: application.hpp:192
Definition: proposal.hpp:17
std::shared_ptr< shared_model::interface::AbstractTransportFactory< shared_model::interface::Query, iroha::protocol::Query > > query_factory
Definition: application.hpp:257
std::unique_ptr< ServerRunner > torii_server
Definition: application.hpp:317
std::shared_ptr< iroha::network::PeerCommunicationService > pcs
Definition: application.hpp:297
rxcpp::composite_subscription consensus_gate_events_subscription
Definition: application.hpp:291
std::shared_ptr< shared_model::interface::AbstractTransportFactory< shared_model::interface::Transaction, iroha::protocol::Transaction > > transaction_factory
Definition: application.hpp:247
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
std::shared_ptr< iroha::MstProcessor > mst_processor
Definition: application.hpp:304
std::shared_ptr< iroha::ametsuchi::WsvRestorer > wsv_restorer_
Definition: application.hpp:219
std::shared_ptr< shared_model::interface::TransactionBatchParser > batch_parser
Definition: application.hpp:227
size_t stale_stream_max_rounds_
Definition: application.hpp:199
std::shared_ptr< iroha::network::ConsensusGate > consensus_gate
Definition: application.hpp:288
Definition: stateful_validator.hpp:19
std::chrono::milliseconds proposal_delay_
Definition: application.hpp:194
Definition: block.hpp:15
std::chrono::milliseconds max_rounds_delay_
Definition: application.hpp:198
std::shared_ptr< shared_model::validation::ValidatorsConfig > validators_config_
Definition: application.hpp:231
Definition: chain_validator.hpp:28
std::shared_ptr< iroha::consensus::ConsensusResultCache > consensus_result_cache_
Definition: application.hpp:282
std::unique_ptr< iroha::consensus::yac::YacInit > yac_init
Definition: application.hpp:211
std::shared_ptr< iroha::ametsuchi::TxPresenceCache > persistent_cache
Definition: application.hpp:266
Definition: server_runner.hpp:17
Definition: block_query.hpp:16
iroha::network::OnDemandOrderingInit ordering_init
Definition: application.hpp:210
std::chrono::milliseconds vote_delay_
Definition: application.hpp:195
std::string pg_conn_
Definition: application.hpp:189
std::shared_ptr< iroha::validation::ChainValidator > chain_validator
Definition: application.hpp:233
Definition: query_service.hpp:35
Definition: application.hpp:73
std::shared_ptr< LoggerManagerTree > LoggerManagerTreePtr
Definition: logger_manager_fwd.hpp:14
std::shared_ptr< iroha::network::OrderingGate > ordering_gate
Definition: application.hpp:275
std::unique_ptr< ServerRunner > internal_server
Definition: application.hpp:318
std::shared_ptr< shared_model::interface::AbstractTransportFactory< shared_model::interface::Proposal, iroha::protocol::Proposal > > proposal_factory
Definition: application.hpp:272
logger::LoggerPtr log_
log for local messages
Definition: application.hpp:322
Definition: on_demand_ordering_init.hpp:32
std::shared_ptr< iroha::simulator::Simulator > simulator
Definition: application.hpp:278
boost::optional< iroha::GossipPropagationStrategyParams > opt_mst_gossip_params_
Definition: application.hpp:201
rxcpp::composite_subscription consensus_gate_objects_lifetime
Definition: application.hpp:289
rxcpp::subjects::subject< iroha::consensus::GateObject > consensus_gate_objects
Definition: application.hpp:290
std::shared_ptr< shared_model::interface::TransactionBatchFactory > transaction_batch_factory_
Definition: application.hpp:241
std::shared_ptr< shared_model::interface::CommonObjectsFactory > common_objects_factory_
Definition: application.hpp:216
Definition: status_bus.hpp:17
Definition: command_service.hpp:26
shared_model::crypto::Keypair keypair
Definition: application.hpp:205
std::shared_ptr< iroha::torii::CommandService > command_service
Definition: application.hpp:310
std::shared_ptr< shared_model::interface::AbstractTransportFactory< shared_model::interface::BlocksQuery, iroha::protocol::BlocksQuery > > blocks_query_factory
Definition: application.hpp:263
std::shared_ptr< iroha::synchronizer::Synchronizer > synchronizer
Definition: application.hpp:294
size_t torii_port_
Definition: application.hpp:191
Definition: command_executor.hpp:12
const std::string listen_ip_
Definition: application.hpp:190
std::shared_ptr< iroha::torii::QueryService > query_service
Definition: application.hpp:315
Definition: transaction.hpp:22
std::shared_ptr< shared_model::interface::QueryResponseFactory > query_response_factory_
Definition: application.hpp:251
Definition: command_service_transport_grpc.hpp:33
size_t max_proposal_size_
Definition: application.hpp:193
Definition: query_processor.hpp:28
std::shared_ptr< iroha::network::BlockLoader > block_loader
Definition: application.hpp:285
std::shared_ptr< iroha::network::MstTransport > mst_transport
Definition: application.hpp:303
Definition: abstract_crypto_model_signer.hpp:16