Line data Source code
1 : /**
2 : * Copyright Soramitsu Co., Ltd. All Rights Reserved.
3 : * SPDX-License-Identifier: Apache-2.0
4 : */
5 :
6 : #include "converters/pb_block_factory.hpp"
7 : #include "converters/pb_common.hpp"
8 : #include "converters/pb_query_factory.hpp"
9 : #include "converters/pb_transaction_factory.hpp"
10 : #include "logger/logger_spdlog.hpp"
11 :
12 : namespace iroha {
13 : // TODO: 24.01.2018 @victordrobny: remove factories IR-850
14 : const static model::converters::PbTransactionFactory tx_factory;
15 : const static model::converters::PbBlockFactory block_factory;
16 : // TODO 10.01.2019 mboldyrev: initialize query_factory logger using config
17 : const static model::converters::PbQueryFactory query_factory(
18 6 : std::make_shared<logger::LoggerSpdlog>(
19 : "QueryFactory",
20 6 : std::make_shared<logger::LoggerConfig>(logger::LoggerConfig{
21 6 : logger::kDefaultLogLevel, logger::getDefaultLogPatterns()})));
22 :
23 : hash256_t hash(const model::Transaction &tx) {
24 5 : auto &&pb_dat = tx_factory.serialize(tx);
25 5 : return hash(pb_dat);
26 5 : }
27 :
28 : hash256_t hash(const model::Block &block) {
29 3 : auto &&pb_dat = block_factory.serialize(block);
30 3 : return hash(pb_dat.block_v1());
31 3 : }
32 :
33 : hash256_t hash(const model::Query &query) {
34 : std::shared_ptr<const model::Query> qptr(&query, [](auto) {});
35 40 : auto &&pb_dat = query_factory.serialize(qptr);
36 40 : return hash(*pb_dat);
37 40 : }
38 : } // namespace iroha
|