TARAXA
taraxa::pillar_chain::PillarVotes Class Reference

#include <pillar_votes.hpp>

Classes

struct  PeriodVotes
 
struct  WeightVotes
 

Public Member Functions

bool voteExists (const std::shared_ptr< PillarVote > vote) const
 Checks if vote exists. More...
 
bool isUniqueVote (const std::shared_ptr< PillarVote > vote) const
 Checks if vote is unique per period & validator. More...
 
bool periodDataInitialized (PbftPeriod period) const
 Checks if specified period data have been already initialized. More...
 
void initializePeriodData (PbftPeriod period, uint64_t threshold)
 Initialize period data with period_two_t_plus_one. More...
 
bool addVerifiedVote (const std::shared_ptr< PillarVote > &vote, uint64_t validator_vote_count)
 Add a vote to the votes map. More...
 
std::vector< std::shared_ptr< PillarVote > > getVerifiedVotes (PbftPeriod period, const blk_hash_t &pillar_block_hash, bool above_threshold=false) const
 Get all pillar block votes for specified pillar block. More...
 
void eraseVotes (PbftPeriod min_period)
 Erases votes wit period < min_period. More...
 

Private Attributes

std::map< PbftPeriod, PeriodVotesvotes_
 
std::shared_mutex mutex_
 

Class Documentation

◆ taraxa::pillar_chain::PillarVotes::PeriodVotes

struct taraxa::pillar_chain::PillarVotes::PeriodVotes
Class Members
unordered_map< blk_hash_t, WeightVotes > pillar_block_votes
uint64_t threshold
unordered_map< addr_t, vote_hash_t > unique_voters

◆ taraxa::pillar_chain::PillarVotes::WeightVotes

struct taraxa::pillar_chain::PillarVotes::WeightVotes
Class Members
unordered_map< vote_hash_t, pair< shared_ptr< PillarVote >, uint64_t > > votes
uint64_t weight

Member Function Documentation

◆ addVerifiedVote()

bool taraxa::pillar_chain::PillarVotes::addVerifiedVote ( const std::shared_ptr< PillarVote > &  vote,
uint64_t  validator_vote_count 
)

Add a vote to the votes map.

Parameters
votevote
validator_vote_count
Returns
true if vote was successfully added, otherwise false

◆ eraseVotes()

void taraxa::pillar_chain::PillarVotes::eraseVotes ( PbftPeriod  min_period)

Erases votes wit period < min_period.

Parameters
min_period

◆ getVerifiedVotes()

std::vector< std::shared_ptr< PillarVote > > taraxa::pillar_chain::PillarVotes::getVerifiedVotes ( PbftPeriod  period,
const blk_hash_t pillar_block_hash,
bool  above_threshold = false 
) const

Get all pillar block votes for specified pillar block.

Parameters
period
pillar_block_hash
above_thresholdif true, return only if there is > threshold verified votes
Returns
all pillar block votes for specified period and pillar block hash. In case above_threshold == true, votes are sorted based on vote weight and the minimum number of votes above threshold are returned

◆ initializePeriodData()

void taraxa::pillar_chain::PillarVotes::initializePeriodData ( PbftPeriod  period,
uint64_t  threshold 
)

Initialize period data with period_two_t_plus_one.

Parameters
period
threshold

◆ isUniqueVote()

bool taraxa::pillar_chain::PillarVotes::isUniqueVote ( const std::shared_ptr< PillarVote vote) const

Checks if vote is unique per period & validator.

Parameters
vote
Returns
true if unique, otherwise false

◆ periodDataInitialized()

bool taraxa::pillar_chain::PillarVotes::periodDataInitialized ( PbftPeriod  period) const

Checks if specified period data have been already initialized.

Parameters
period
Returns
true if initialized, othwrwise false

◆ voteExists()

bool taraxa::pillar_chain::PillarVotes::voteExists ( const std::shared_ptr< PillarVote vote) const

Checks if vote exists.

Parameters
vote
Returns
true if exists, otherwise false

Member Data Documentation

◆ mutex_

std::shared_mutex taraxa::pillar_chain::PillarVotes::mutex_
mutableprivate

◆ votes_

std::map<PbftPeriod, PeriodVotes> taraxa::pillar_chain::PillarVotes::votes_
private

The documentation for this class was generated from the following files: