6 #ifndef KAGOME_CORE_CONSENSUS_GRANDPA_VOTER_SET_HPP 7 #define KAGOME_CORE_CONSENSUS_GRANDPA_VOTER_SET_HPP 46 const Id &voter)
const;
65 inline size_t size()
const {
82 std::unordered_map<Id, Index>
map_;
83 std::vector<std::tuple<const Id &, Weight>>
list_;
86 template <
class Stream>
88 template <
class Stream>
93 typename = std::enable_if_t<Stream::is_encoder_stream>>
95 return s << voters.
list_ << voters.
id_;
99 typename = std::enable_if_t<Stream::is_decoder_stream>>
101 voters.
list_.clear();
105 std::vector<std::tuple<Id, VoterSet::Weight>> list;
106 s >> list >> voters.
id_;
107 for (
const auto &[
id, weight] : list) {
108 auto r = voters.
insert(
id, weight);
120 #endif // KAGOME_CORE_CONSENSUS_GRANDPA_VOTER_SET_HPP OUTCOME_HPP_DECLARE_ERROR(kagome::consensus::grandpa, VoterSet::Error)
void raise(T t)
throws outcome::result error as boost exception
outcome::result< void > insert(Id voter, Weight weight)
std::optional< Index > voterIndex(const Id &voter) const
std::optional< std::tuple< Index, Weight > > indexAndWeight(const Id &voter) const
crypto::Ed25519PublicKey Id
friend Stream & operator>>(Stream &s, VoterSet &voters)
std::unordered_map< Id, Index > map_
std::optional< Weight > voterWeight(const Id &voter) const
libp2p::connection::Stream Stream
outcome::result< Id > voterId(Index index) const
std::vector< std::tuple< const Id &, Weight > > list_
friend Stream & operator<<(Stream &s, const VoterSet &voters)
Weight totalWeight() const