LCOV - code coverage report
Current view: top level - irohad/consensus/yac - outcome_messages.hpp (source / functions) Hit Total Coverage
Test: cleared_cor.info Lines: 2 2 100.0 %
Date: 2019-03-07 14:46:43 Functions: 19 19 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_MESSAGES_HPP
       7             : #define IROHA_MESSAGES_HPP
       8             : 
       9             : #include <vector>
      10             : 
      11             : #include "consensus/yac/vote_message.hpp"
      12             : #include "utils/string_builder.hpp"
      13             : 
      14             : namespace iroha {
      15             :   namespace consensus {
      16             :     namespace yac {
      17             : 
      18             :       /**
      19             :        * CommitMsg means consensus on cluster achieved.
      20             :        * All nodes deals on some solution
      21             :        */
      22             :       struct CommitMessage {
      23             :         explicit CommitMessage(std::vector<VoteMessage> votes)
      24        3180 :             : votes(std::move(votes)) {}
      25             : 
      26             :         std::vector<VoteMessage> votes;
      27             : 
      28             :         bool operator==(const CommitMessage &rhs) const {
      29             :           return votes == rhs.votes;
      30             :         }
      31             : 
      32             :         std::string toString() const {
      33             :           return shared_model::detail::PrettyStringBuilder()
      34             :               .init("CommitMessage")
      35             :               .appendAll(
      36             :                   "votes", votes, [](auto vote) { return vote.toString(); })
      37             :               .finalize();
      38             :         }
      39             :       };
      40             : 
      41             :       /**
      42             :        * Reject means that there is impossible
      43             :        * to collect supermajority for any block
      44             :        */
      45             :       struct RejectMessage {
      46             :         explicit RejectMessage(std::vector<VoteMessage> votes)
      47          10 :             : votes(std::move(votes)) {}
      48             : 
      49             :         std::vector<VoteMessage> votes;
      50             : 
      51             :         bool operator==(const RejectMessage &rhs) const {
      52             :           return votes == rhs.votes;
      53             :         }
      54             : 
      55             :         std::string toString() const {
      56             :           return shared_model::detail::PrettyStringBuilder()
      57             :               .init("RejectMessage")
      58             :               .appendAll(
      59             :                   "votes", votes, [](auto vote) { return vote.toString(); })
      60             :               .finalize();
      61             :         }
      62             :       };
      63             :     }  // namespace yac
      64             :   }    // namespace consensus
      65             : }  // namespace iroha
      66             : #endif  // IROHA_MESSAGES_HPP

Generated by: LCOV version 1.13