Kagome
Polkadot Runtime Engine in C++17
|
#include <voter_set.hpp>
Public Types | |
enum | Error { Error::VOTER_ALREADY_EXISTS = 1, Error::INDEX_OUTBOUND } |
using | Index = size_t |
using | Weight = size_t |
Public Member Functions | |
VoterSet ()=default | |
VoterSet (VoterSetId id_of_set) | |
outcome::result< void > | insert (Id voter, Weight weight) |
VoterSetId | id () const |
std::optional< std::tuple< Index, Weight > > | indexAndWeight (const Id &voter) const |
outcome::result< Id > | voterId (Index index) const |
std::optional< Index > | voterIndex (const Id &voter) const |
std::optional< Weight > | voterWeight (const Id &voter) const |
outcome::result< Weight > | voterWeight (Index voter_index) const |
size_t | size () const |
bool | empty () const |
Weight | totalWeight () const |
Private Attributes | |
VoterSetId | id_ {} |
std::unordered_map< Id, Index > | map_ |
std::vector< std::tuple< const Id &, Weight > > | list_ |
size_t | total_weight_ {0} |
Friends | |
template<class Stream > | |
Stream & | operator<< (Stream &s, const VoterSet &voters) |
template<class Stream > | |
Stream & | operator>> (Stream &s, VoterSet &voters) |
Stores voters with their corresponding weights
Definition at line 19 of file voter_set.hpp.
using kagome::consensus::grandpa::VoterSet::Index = size_t |
Definition at line 26 of file voter_set.hpp.
using kagome::consensus::grandpa::VoterSet::Weight = size_t |
Definition at line 27 of file voter_set.hpp.
|
strong |
Enumerator | |
---|---|
VOTER_ALREADY_EXISTS | |
INDEX_OUTBOUND |
Definition at line 21 of file voter_set.hpp.
|
default |
|
explicit |
Definition at line 21 of file voter_set.cpp.
|
inline |
Definition at line 69 of file voter_set.hpp.
|
inline |
Definition at line 41 of file voter_set.hpp.
std::optional< std::tuple< VoterSet::Index, VoterSet::Weight > > kagome::consensus::grandpa::VoterSet::indexAndWeight | ( | const Id & | voter | ) | const |
Definition at line 49 of file voter_set.cpp.
|
inline |
Definition at line 65 of file voter_set.hpp.
|
inline |
Definition at line 76 of file voter_set.hpp.
Definition at line 40 of file voter_set.cpp.
std::optional< VoterSet::Index > kagome::consensus::grandpa::VoterSet::voterIndex | ( | const Id & | voter | ) | const |
std::optional< VoterSet::Weight > kagome::consensus::grandpa::VoterSet::voterWeight | ( | const Id & | voter | ) | const |
outcome::result< VoterSet::Weight > kagome::consensus::grandpa::VoterSet::voterWeight | ( | Index | voter_index | ) | const |
|
friend |
Definition at line 94 of file voter_set.hpp.
|
friend |
Definition at line 100 of file voter_set.hpp.
|
private |
Definition at line 81 of file voter_set.hpp.
Definition at line 83 of file voter_set.hpp.
Definition at line 82 of file voter_set.hpp.
|
private |
Definition at line 84 of file voter_set.hpp.