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/round.hpp"
7 :
8 : #include <boost/functional/hash.hpp>
9 : #include <tuple>
10 : #include <utility>
11 :
12 : #include "utils/string_builder.hpp"
13 :
14 : namespace iroha {
15 : namespace consensus {
16 : Round::Round(BlockRoundType block_r, RejectRoundType reject_r)
17 3192 : : block_round{block_r}, reject_round{reject_r} {}
18 :
19 : bool Round::operator<(const Round &rhs) const {
20 0 : return std::tie(block_round, reject_round)
21 0 : < std::tie(rhs.block_round, rhs.reject_round);
22 : }
23 :
24 : bool Round::operator==(const Round &rhs) const {
25 13705 : return std::tie(block_round, reject_round)
26 13705 : == std::tie(rhs.block_round, rhs.reject_round);
27 : }
28 :
29 : bool Round::operator!=(const Round &rhs) const {
30 0 : return not(*this == rhs);
31 : }
32 :
33 : std::size_t RoundTypeHasher::operator()(const consensus::Round &val) const {
34 3158 : size_t seed = 0;
35 3158 : boost::hash_combine(seed, val.block_round);
36 3158 : boost::hash_combine(seed, val.reject_round);
37 3158 : return seed;
38 : }
39 :
40 : std::string Round::toString() const {
41 0 : return shared_model::detail::PrettyStringBuilder()
42 0 : .init("Round")
43 0 : .append("block", std::to_string(block_round))
44 0 : .append("reject", std::to_string(reject_round))
45 0 : .finalize();
46 0 : }
47 : } // namespace consensus
48 : } // namespace iroha
|