LCOV - code coverage report
Current view: top level - irohad/consensus/yac/storage/impl - yac_common.cpp (source / functions) Hit Total Coverage
Test: cleared_cor.info Lines: 12 14 85.7 %
Date: 2019-03-07 14:46:43 Functions: 4 4 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/storage/yac_common.hpp"
       7             : 
       8             : #include <algorithm>
       9             : 
      10             : #include "consensus/yac/outcome_messages.hpp"
      11             : 
      12             : namespace iroha {
      13             :   namespace consensus {
      14             :     namespace yac {
      15             : 
      16             :       bool sameKeys(const std::vector<VoteMessage> &votes) {
      17       13820 :         if (votes.empty()) {
      18           0 :           return false;
      19             :         }
      20             : 
      21       13820 :         auto first = votes.at(0);
      22       13820 :         return std::all_of(
      23             :             votes.begin(), votes.end(), [&first](const auto &current) {
      24       15552 :               return first.hash.vote_round == current.hash.vote_round;
      25             :             });
      26       13821 :       }
      27             : 
      28             :       boost::optional<Round> getKey(const std::vector<VoteMessage> &votes) {
      29           2 :         if (not sameKeys(votes)) {
      30           1 :           return boost::none;
      31             :         }
      32           1 :         return votes[0].hash.vote_round;
      33           2 :       }
      34             : 
      35             :       boost::optional<YacHash> getHash(const std::vector<VoteMessage> &votes) {
      36        6264 :         if (not sameKeys(votes)) {
      37           0 :           return boost::none;
      38             :         }
      39             : 
      40        6264 :         return votes.at(0).hash;
      41        6264 :       }
      42             :     }  // namespace yac
      43             :   }    // namespace consensus
      44             : }  // namespace iroha

Generated by: LCOV version 1.13