6 #ifndef KAGOME_CORE_CONSENSUS_GRANDPA_VOTE_WEIGHT_HPP 7 #define KAGOME_CORE_CONSENSUS_GRANDPA_VOTE_WEIGHT_HPP 11 #include <boost/dynamic_bitset.hpp> 12 #include <boost/operators.hpp> 23 class VoteWeight :
public boost::equality_comparable<VoteWeight>,
24 public boost::less_than_comparable<VoteWeight> {
32 void set(
size_t index,
size_t weight) {
33 if (flags.size() <= index) {
34 flags.resize(index + 1, 0);
43 void unset(
size_t index,
size_t weight) {
44 if (flags.size() <= index) {
47 if (not flags[index]) {
58 for (
size_t i = voter_set.
size(); i > 0;) {
61 if ((flags.size() <= i or not flags[i]) and equivocators.size() > i
62 and equivocators[i]) {
71 const std::shared_ptr<VoterSet> &voter_set) {
72 for (
auto i = other.
flags.size(); i > 0;) {
75 set(i, voter_set->voterWeight(i).value());
81 return sum == other.
sum and flags == other.
flags;
92 BOOST_UNREACHABLE_RETURN({});
95 void set(
VoteType vote_type,
size_t index,
size_t weight) {
102 BOOST_UNREACHABLE_RETURN();
112 BOOST_UNREACHABLE_RETURN();
116 const std::vector<bool> &equivocators,
124 BOOST_UNREACHABLE_RETURN({});
128 const std::shared_ptr<VoterSet> &voter_set) {
145 #endif // KAGOME_CORE_CONSENSUS_GRANDPA_VOTE_WEIGHT_HPP OneTypeVoteWeight prevotes_weight
bool operator==(const VoteWeight &other) const
void merge(const OneTypeVoteWeight &other, const std::shared_ptr< VoterSet > &voter_set)
void unset(VoteType vote_type, size_t index, size_t weight)
std::vector< bool > flags
OneTypeVoteWeight precommits_weight
Weight sum(VoteType vote_type) const
void merge(const VoteWeight &other, const std::shared_ptr< VoterSet > &voter_set)
void unset(size_t index, size_t weight)
Weight total(VoteType vote_type, const std::vector< bool > &equivocators, const VoterSet &voter_set) const
std::optional< Weight > voterWeight(const Id &voter) const
bool operator==(const OneTypeVoteWeight &other) const
void set(size_t index, size_t weight)
Weight total(const std::vector< bool > &equivocators, const VoterSet &voter_set) const