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 "logger/logger.hpp"
17 
18 namespace iroha {
19  class PendingTransactionStorage;
20  class MstProcessor;
21  namespace ametsuchi {
22  class WsvRestorer;
23  class TxPresenceCache;
24  class Storage;
25  } // namespace ametsuchi
26  namespace network {
27  class BlockLoader;
28  class ConsensusGate;
29  class PeerCommunicationService;
30  class MstTransport;
31  class OrderingGate;
32  } // namespace network
33  namespace simulator {
34  class Simulator;
35  }
36  namespace synchronizer {
37  class Synchronizer;
38  }
39  namespace torii {
40  class QueryProcessor;
41  class StatusBus;
42  class CommandService;
44  class QueryService;
45  } // namespace torii
46  namespace validation {
47  class ChainValidator;
48  class StatefulValidator;
49  } // namespace validation
50 } // namespace iroha
51 
52 namespace shared_model {
53  namespace crypto {
54  class Keypair;
55  }
56  namespace interface {
57  class CommonObjectsFactory;
58  class QueryResponseFactory;
59  class TransactionBatchFactory;
60  } // namespace interface
61 } // namespace shared_model
62 
63 class ServerRunner;
64 
65 class Irohad {
66  public:
67  using RunResult = iroha::expected::Result<void, std::string>;
68 
88  Irohad(const std::string &block_store_dir,
89  const std::string &pg_conn,
90  const std::string &listen_ip,
91  size_t torii_port,
92  size_t internal_port,
93  size_t max_proposal_size,
94  std::chrono::milliseconds proposal_delay,
95  std::chrono::milliseconds vote_delay,
96  std::chrono::minutes mst_expiration_time,
97  const shared_model::crypto::Keypair &keypair,
98  const boost::optional<iroha::GossipPropagationStrategyParams>
99  &opt_mst_gossip_params = boost::none);
100 
104  virtual void init();
105 
110  bool restoreWsv();
111 
115  virtual void dropStorage();
116 
121  RunResult run();
122 
123  virtual ~Irohad();
124 
125  protected:
126  // -----------------------| component initialization |------------------------
127 
128  virtual void initStorage();
129 
130  virtual void initCryptoProvider();
131 
132  virtual void initBatchParser();
133 
134  virtual void initValidators();
135 
136  virtual void initNetworkClient();
137 
138  virtual void initFactories();
139 
140  virtual void initPersistentCache();
141 
142  virtual void initOrderingGate();
143 
144  virtual void initSimulator();
145 
146  virtual void initConsensusCache();
147 
148  virtual void initBlockLoader();
149 
150  virtual void initConsensusGate();
151 
152  virtual void initSynchronizer();
153 
154  virtual void initPeerCommunicationService();
155 
156  virtual void initStatusBus();
157 
158  virtual void initMstProcessor();
159 
160  virtual void initPendingTxsStorage();
161 
162  virtual void initTransactionCommandService();
163 
164  virtual void initQueryService();
165 
169  virtual void initWsvRestorer();
170 
171  // constructor dependencies
175  size_t torii_port_;
178  std::chrono::milliseconds proposal_delay_;
179  std::chrono::milliseconds vote_delay_;
181  std::chrono::minutes mst_expiration_time_;
182  boost::optional<iroha::GossipPropagationStrategyParams>
184 
185  // ------------------------| internal dependencies |-------------------------
186  public:
188  std::shared_ptr<iroha::ametsuchi::Storage> storage;
189 
190  protected:
192 
193  // initialization objects
197 
198  // common objects factory
199  std::shared_ptr<shared_model::interface::CommonObjectsFactory>
201 
202  // WSV restorer
203  std::shared_ptr<iroha::ametsuchi::WsvRestorer> wsv_restorer_;
204 
205  // crypto provider
209 
210  // batch parser
211  std::shared_ptr<shared_model::interface::TransactionBatchParser> batch_parser;
212 
213  // validators
214  std::shared_ptr<iroha::validation::StatefulValidator> stateful_validator;
215  std::shared_ptr<iroha::validation::ChainValidator> chain_validator;
216 
217  // async call
218  std::shared_ptr<iroha::network::AsyncGrpcClient<google::protobuf::Empty>>
220 
221  // transaction batch factory
222  std::shared_ptr<shared_model::interface::TransactionBatchFactory>
224 
225  // transaction factory
230 
231  // query response factory
232  std::shared_ptr<shared_model::interface::QueryResponseFactory>
234 
235  // query factory
240 
241  // persistent cache
242  std::shared_ptr<iroha::ametsuchi::TxPresenceCache> persistent_cache;
243 
244  // proposal factory
247  iroha::protocol::Proposal>>
249 
250  // ordering gate
251  std::shared_ptr<iroha::network::OrderingGate> ordering_gate;
252 
253  // simulator
254  std::shared_ptr<iroha::simulator::Simulator> simulator;
255 
256  // block cache for consensus and block loader
257  std::shared_ptr<iroha::consensus::ConsensusResultCache>
259 
260  // block loader
261  std::shared_ptr<iroha::network::BlockLoader> block_loader;
262 
263  // consensus gate
264  std::shared_ptr<iroha::network::ConsensusGate> consensus_gate;
265  rxcpp::subjects::subject<iroha::consensus::GateObject> consensus_gate_objects;
266  rxcpp::composite_subscription consensus_gate_events_subscription;
267 
268  // synchronizer
269  std::shared_ptr<iroha::synchronizer::Synchronizer> synchronizer;
270 
271  // pcs
272  std::shared_ptr<iroha::network::PeerCommunicationService> pcs;
273 
274  // status bus
275  std::shared_ptr<iroha::torii::StatusBus> status_bus_;
276 
277  // mst
278  std::shared_ptr<iroha::network::MstTransport> mst_transport;
279  std::shared_ptr<iroha::MstProcessor> mst_processor;
280 
281  // pending transactions storage
282  std::shared_ptr<iroha::PendingTransactionStorage> pending_txs_storage_;
283 
284  // transaction service
285  std::shared_ptr<iroha::torii::CommandService> command_service;
286  std::shared_ptr<iroha::torii::CommandServiceTransportGrpc>
288 
289  // query service
290  std::shared_ptr<iroha::torii::QueryService> query_service;
291 
292  std::unique_ptr<ServerRunner> torii_server;
293  std::unique_ptr<ServerRunner> internal_server;
294 };
295 
296 #endif // IROHA_APPLICATION_HPP
iroha::expected::Result< void, std::string > RunResult
Definition: application.hpp:67
std::shared_ptr< iroha::torii::StatusBus > status_bus_
Definition: application.hpp:275
std::shared_ptr< shared_model::crypto::AbstractCryptoModelSigner< shared_model::interface::Block > > crypto_signer_
Definition: application.hpp:208
logger::Logger log_
Definition: application.hpp:191
iroha::network::BlockLoaderInit loader_init
Definition: application.hpp:196
std::shared_ptr< iroha::torii::CommandServiceTransportGrpc > command_service_transport
Definition: application.hpp:287
std::shared_ptr< iroha::PendingTransactionStorage > pending_txs_storage_
Definition: application.hpp:282
Definition: command_client.hpp:16
bool is_mst_supported_
Definition: application.hpp:180
Definition: query.hpp:34
std::shared_ptr< iroha::validation::StatefulValidator > stateful_validator
Definition: application.hpp:214
std::string block_store_dir_
Definition: application.hpp:172
std::shared_ptr< iroha::network::AsyncGrpcClient< google::protobuf::Empty > > async_call_
Definition: application.hpp:219
std::chrono::minutes mst_expiration_time_
Definition: application.hpp:181
iroha::consensus::yac::YacInit yac_init
Definition: application.hpp:195
Definition: block_loader_init.hpp:19
Definition: synchronizer.hpp:19
Definition: consensus_init.hpp:31
Definition: keypair.hpp:19
std::shared_ptr< iroha::ametsuchi::Storage > storage
Definition: application.hpp:188
size_t internal_port_
Definition: application.hpp:176
Definition: proposal.hpp:17
std::shared_ptr< shared_model::interface::AbstractTransportFactory< shared_model::interface::Query, iroha::protocol::Query > > query_factory
Definition: application.hpp:239
std::unique_ptr< ServerRunner > torii_server
Definition: application.hpp:292
string(REPLACE".""/"CMAKE_SWIG_OUTDIR ${SWIG_JAVA_PKG}) else() set(CMAKE_SWIG_FLAGS"") endif() myswig_add_library(irohajava LANGUAGE java SOURCES bindings.i) unset(CMAKE_SWIG_FLAGS) swig_link_libraries(irohajava $
Definition: CMakeLists.txt:54
std::shared_ptr< iroha::network::PeerCommunicationService > pcs
Definition: application.hpp:272
rxcpp::composite_subscription consensus_gate_events_subscription
Definition: application.hpp:266
std::shared_ptr< shared_model::interface::AbstractTransportFactory< shared_model::interface::Transaction, iroha::protocol::Transaction > > transaction_factory
Definition: application.hpp:229
std::shared_ptr< iroha::MstProcessor > mst_processor
Definition: application.hpp:279
std::shared_ptr< iroha::ametsuchi::WsvRestorer > wsv_restorer_
Definition: application.hpp:203
std::shared_ptr< spdlog::logger > Logger
Definition: logger.hpp:26
std::shared_ptr< shared_model::interface::TransactionBatchParser > batch_parser
Definition: application.hpp:211
std::shared_ptr< iroha::network::ConsensusGate > consensus_gate
Definition: application.hpp:264
Definition: stateful_validator.hpp:19
std::chrono::milliseconds proposal_delay_
Definition: application.hpp:178
Definition: block.hpp:15
Definition: chain_validator.hpp:28
std::shared_ptr< iroha::consensus::ConsensusResultCache > consensus_result_cache_
Definition: application.hpp:258
std::shared_ptr< iroha::ametsuchi::TxPresenceCache > persistent_cache
Definition: application.hpp:242
Definition: server_runner.hpp:17
Definition: block_query.hpp:16
iroha::network::OnDemandOrderingInit ordering_init
Definition: application.hpp:194
std::chrono::milliseconds vote_delay_
Definition: application.hpp:179
std::string pg_conn_
Definition: application.hpp:173
std::shared_ptr< iroha::validation::ChainValidator > chain_validator
Definition: application.hpp:215
Definition: query_service.hpp:36
Definition: application.hpp:65
std::shared_ptr< iroha::network::OrderingGate > ordering_gate
Definition: application.hpp:251
std::unique_ptr< ServerRunner > internal_server
Definition: application.hpp:293
std::shared_ptr< shared_model::interface::AbstractTransportFactory< shared_model::interface::Proposal, iroha::protocol::Proposal > > proposal_factory
Definition: application.hpp:248
Definition: on_demand_ordering_init.hpp:30
std::shared_ptr< iroha::simulator::Simulator > simulator
Definition: application.hpp:254
boost::optional< iroha::GossipPropagationStrategyParams > opt_mst_gossip_params_
Definition: application.hpp:183
rxcpp::subjects::subject< iroha::consensus::GateObject > consensus_gate_objects
Definition: application.hpp:265
std::shared_ptr< shared_model::interface::TransactionBatchFactory > transaction_batch_factory_
Definition: application.hpp:223
std::shared_ptr< shared_model::interface::CommonObjectsFactory > common_objects_factory_
Definition: application.hpp:200
Definition: status_bus.hpp:17
Definition: command_service.hpp:26
shared_model::crypto::Keypair keypair
Definition: application.hpp:187
std::shared_ptr< iroha::torii::CommandService > command_service
Definition: application.hpp:285
std::shared_ptr< iroha::synchronizer::Synchronizer > synchronizer
Definition: application.hpp:269
size_t torii_port_
Definition: application.hpp:175
Definition: command_executor.hpp:12
const std::string listen_ip_
Definition: application.hpp:174
std::shared_ptr< iroha::torii::QueryService > query_service
Definition: application.hpp:290
Definition: transaction.hpp:22
std::shared_ptr< shared_model::interface::QueryResponseFactory > query_response_factory_
Definition: application.hpp:233
Definition: command_service_transport_grpc.hpp:33
size_t max_proposal_size_
Definition: application.hpp:177
Definition: query_processor.hpp:28
std::shared_ptr< iroha::network::BlockLoader > block_loader
Definition: application.hpp:261
std::shared_ptr< iroha::network::MstTransport > mst_transport
Definition: application.hpp:278
Definition: abstract_crypto_model_signer.hpp:16