Line data Source code
1 : /**
2 : * Copyright Soramitsu Co., Ltd. All Rights Reserved.
3 : * SPDX-License-Identifier: Apache-2.0
4 : */
5 :
6 : #include "consensus/yac/impl/yac_hash_provider_impl.hpp"
7 : #include "interfaces/iroha_internal/block.hpp"
8 :
9 : namespace iroha {
10 : namespace consensus {
11 : namespace yac {
12 :
13 : YacHash YacHashProviderImpl::makeHash(
14 : const shared_model::interface::Block &block) const {
15 710 : YacHash result;
16 710 : auto hex_hash = block.hash().hex();
17 710 : result.vote_round = {block.height(), 1};
18 710 : result.vote_hashes.proposal_hash = hex_hash;
19 710 : result.vote_hashes.block_hash = hex_hash;
20 710 : result.block_signature = clone(block.signatures().front());
21 710 : return result;
22 710 : }
23 :
24 : shared_model::interface::types::HashType YacHashProviderImpl::toModelHash(
25 : const YacHash &hash) const {
26 1 : auto blob = shared_model::crypto::Blob::fromHexString(
27 1 : hash.vote_hashes.block_hash);
28 1 : auto string_blob = shared_model::crypto::toBinaryString(blob);
29 1 : return shared_model::interface::types::HashType(string_blob);
30 1 : }
31 : } // namespace yac
32 : } // namespace consensus
33 : } // namespace iroha
|