LCOV - code coverage report
Current view: top level - irohad/consensus/yac/impl - yac_hash_provider_impl.cpp (source / functions) Hit Total Coverage
Test: cleared_cor.info Lines: 16 16 100.0 %
Date: 2019-03-07 14:46:43 Functions: 2 2 100.0 %

          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             : #include "interfaces/iroha_internal/proposal.hpp"
       9             : 
      10             : namespace iroha {
      11             :   namespace consensus {
      12             :     namespace yac {
      13             : 
      14             :       YacHash YacHashProviderImpl::makeHash(
      15             :           const simulator::BlockCreatorEvent &event) const {
      16        3375 :         YacHash result;
      17        3375 :         if (event.round_data) {
      18         723 :           result.vote_hashes.proposal_hash =
      19         723 :               event.round_data->proposal->hash().hex();
      20         723 :           result.vote_hashes.block_hash = event.round_data->block->hash().hex();
      21         723 :           result.block_signature =
      22         723 :               clone(event.round_data->block->signatures().front());
      23         723 :         }
      24        3375 :         result.vote_round = event.round;
      25             : 
      26        3375 :         return result;
      27        3375 :       }
      28             : 
      29             :       shared_model::interface::types::HashType YacHashProviderImpl::toModelHash(
      30             :           const YacHash &hash) const {
      31           1 :         auto blob = shared_model::crypto::Blob::fromHexString(
      32           1 :             hash.vote_hashes.block_hash);
      33           1 :         auto string_blob = shared_model::crypto::toBinaryString(blob);
      34           1 :         return shared_model::interface::types::HashType(string_blob);
      35           1 :       }
      36             : 
      37             :     }  // namespace yac
      38             :   }    // namespace consensus
      39             : }  // namespace iroha

Generated by: LCOV version 1.13