LCOV - code coverage report
Current view: top level - irohad/validation - utils.hpp (source / functions) Hit Total Coverage
Test: coverage_cleared.info Lines: 7 9 77.8 %
Date: 2018-12-05 17:11:35 Functions: 3 3 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_VALIDATION_UTILS
       7             : #define IROHA_VALIDATION_UTILS
       8             : 
       9             : #include <string>
      10             : #include <vector>
      11             : 
      12             : #include <boost/range/any_range.hpp>
      13             : 
      14             : #include "cryptography/public_key.hpp"
      15             : #include "interfaces/common_objects/types.hpp"
      16             : 
      17             : namespace iroha {
      18             :   namespace validation {
      19             :     /**
      20             :      * Checks if signatures' public keys are present in vector of pubkeys
      21             :      * @param signatures - collection of signatures
      22             :      * @param public_keys - collection of public keys
      23             :      * @return true, if all public keys of signatures are present in vector of
      24             :      * pubkeys
      25             :      */
      26             :     inline bool signaturesSubset(
      27             :         const shared_model::interface::types::SignatureRangeType &signatures,
      28             :         const boost::any_range<shared_model::crypto::PublicKey,
      29             :                                boost::forward_traversal_tag> &public_keys) {
      30         153 :       return std::all_of(
      31         152 :           signatures.begin(),
      32         152 :           signatures.end(),
      33             :           [&public_keys](const auto &signature) {
      34         170 :             return std::find_if(public_keys.begin(),
      35         169 :                                 public_keys.end(),
      36             :                                 [&signature](const auto &public_key) {
      37         211 :                                   return signature.publicKey() == public_key;
      38             :                                 })
      39         170 :                 != public_keys.end();
      40           0 :           });
      41           0 :     }
      42             : 
      43             :   }  // namespace validation
      44             : }  // namespace iroha
      45             : 
      46             : #endif  // IROHA_VALIDATION_UTILS

Generated by: LCOV version 1.13