hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
supermajority_checker.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_CONSENSUS_SUPERMAJORITY_CHECKER_HPP
7 #define IROHA_CONSENSUS_SUPERMAJORITY_CHECKER_HPP
8 
9 #include <memory>
10 #include <vector>
11 
12 #include <boost/range/any_range.hpp>
17 
18 namespace shared_model::interface {
19  class Peer;
20 } // namespace shared_model::interface
21 
22 namespace iroha::consensus::yac {
27  public:
28  using VoteGroups = boost::any_range<PeersNumberType,
29  boost::forward_traversal_tag,
30  // reference type must be const for
31  // transform_iterator to be able to
32  // assign to any_iterator safely
33  const PeersNumberType,
34  std::ptrdiff_t>;
35 
36  virtual ~SupermajorityChecker() = default;
37 
44  virtual bool hasSupermajority(PeersNumberType current,
45  PeersNumberType all) const = 0;
46 
53  virtual bool isTolerated(PeersNumberType number,
54  PeersNumberType all) const = 0;
55 
62  virtual bool canHaveSupermajority(const VoteGroups &votes,
63  PeersNumberType all) const = 0;
64  };
65 
67  std::unique_ptr<SupermajorityChecker> getSupermajorityChecker(
69 } // namespace iroha::consensus::yac
70 
71 #endif // IROHA_CONSENSUS_SUPERMAJORITY_CHECKER_HPP
std::unique_ptr< SupermajorityChecker > getSupermajorityChecker(ConsistencyModel c)
Get a SupermajorityChecker for the given consistency model.
Definition: supermajority_checker_getter.cpp:14
boost::any_range< PeersNumberType, boost::forward_traversal_tag, const PeersNumberType, std::ptrdiff_t > VoteGroups
Definition: supermajority_checker.hpp:34
Definition: command_executor.hpp:14
size_t PeersNumberType
Type for number of peers in round.
Definition: yac_types.hpp:13
ConsistencyModel
Definition: consistency_model.hpp:10
Definition: supermajority_checker.hpp:26
Definition: cluster_order.hpp:16