Line data Source code
1 : /**
2 : * Copyright Soramitsu Co., Ltd. All Rights Reserved.
3 : * SPDX-License-Identifier: Apache-2.0
4 : */
5 :
6 : #include "main/impl/block_loader_init.hpp"
7 :
8 : #include "logger/logger_manager.hpp"
9 : #include "validators/default_validator.hpp"
10 : #include "validators/protobuf/proto_block_validator.hpp"
11 :
12 : using namespace iroha;
13 : using namespace iroha::ametsuchi;
14 : using namespace iroha::network;
15 :
16 : auto BlockLoaderInit::createService(
17 : std::shared_ptr<BlockQueryFactory> block_query_factory,
18 : std::shared_ptr<consensus::ConsensusResultCache> consensus_result_cache,
19 : const logger::LoggerManagerTreePtr &loader_log_manager) {
20 247 : return std::make_shared<BlockLoaderService>(
21 247 : std::move(block_query_factory),
22 247 : std::move(consensus_result_cache),
23 247 : loader_log_manager->getChild("Network")->getLogger());
24 0 : }
25 :
26 : auto BlockLoaderInit::createLoader(
27 : std::shared_ptr<PeerQueryFactory> peer_query_factory,
28 : logger::LoggerPtr loader_log) {
29 247 : shared_model::proto::ProtoBlockFactory factory(
30 247 : std::make_unique<shared_model::validation::DefaultSignedBlockValidator>(),
31 247 : std::make_unique<shared_model::validation::ProtoBlockValidator>());
32 247 : return std::make_shared<BlockLoaderImpl>(
33 247 : std::move(peer_query_factory), std::move(factory), std::move(loader_log));
34 247 : }
35 :
36 : std::shared_ptr<BlockLoader> BlockLoaderInit::initBlockLoader(
37 : std::shared_ptr<PeerQueryFactory> peer_query_factory,
38 : std::shared_ptr<BlockQueryFactory> block_query_factory,
39 : std::shared_ptr<consensus::ConsensusResultCache> consensus_result_cache,
40 : const logger::LoggerManagerTreePtr &loader_log_manager) {
41 247 : service = createService(std::move(block_query_factory),
42 247 : std::move(consensus_result_cache),
43 247 : loader_log_manager);
44 247 : loader = createLoader(std::move(peer_query_factory),
45 247 : loader_log_manager->getLogger());
46 247 : return loader;
47 0 : }
|