LCOV - code coverage report
Current view: top level - shared_model/interfaces/iroha_internal - transaction_batch_helpers.hpp (source / functions) Hit Total Coverage
Test: coverage_cleared.info Lines: 6 6 100.0 %
Date: 2018-12-05 17:11:35 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             : #ifndef IROHA_TRANSACTION_BATCH_HELPERS_HPP
       7             : #define IROHA_TRANSACTION_BATCH_HELPERS_HPP
       8             : 
       9             : #include <sstream>
      10             : 
      11             : #include "cryptography/hash.hpp"
      12             : 
      13             : namespace shared_model {
      14             :   namespace interface {
      15             : 
      16             :     /**
      17             :      * Provides a method that calculates reduced batch hash
      18             :      */
      19             :     class TransactionBatchHelpers {
      20             :      public:
      21             :       /**
      22             :        * Get the concatenation of reduced hashes as a single hash
      23             :        * That kind of hash does not respect batch type
      24             :        * @tparam Collection type of const ref iterator
      25             :        * @param reduced_hashes
      26             :        * @return concatenated reduced hashes
      27             :        */
      28             :       template <typename Collection>
      29             :       static types::HashType calculateReducedBatchHash(
      30             :           const Collection &reduced_hashes) {
      31         211 :         std::stringstream concatenated_hash;
      32         694 :         for (const auto &hash : reduced_hashes) {
      33         483 :           concatenated_hash << hash.hex();
      34         166 :         }
      35         211 :         return types::HashType::fromHexString(concatenated_hash.str());
      36         211 :       }
      37             :     };
      38             :   }  // namespace interface
      39             : }  // namespace shared_model
      40             : 
      41             : #endif  // IROHA_TRANSACTION_BATCH_HELPERS_HPP

Generated by: LCOV version 1.13