TARAXA
taraxa::rewards::BlockStats Class Reference

#include <block_stats.hpp>

Collaboration diagram for taraxa::rewards::BlockStats:

Classes

struct  ValidatorStats
 

Public Member Functions

 BlockStats ()=default
 
 BlockStats (const PeriodData &block, const std::vector< gas_t > &trxs_gas_used, uint64_t dpos_vote_count, uint32_t committee_size, const bool aspen_dag_rewards=false)
 setting block_author_, max_votes_weight_ and calls processStats function More...
 

Protected Attributes

addr_t block_author_
 
std::unordered_map< trx_hash_t, u256fee_by_trx_hash_
 
std::unordered_map< addr_t, ValidatorStatsvalidators_stats_
 
uint32_t total_dag_blocks_count_ {0}
 
uint64_t total_votes_weight_ {0}
 
uint64_t max_votes_weight_ {0}
 

Private Member Functions

void processStats (const PeriodData &block, const bool aspen_dag_rewards)
 Process PeriodData and save stats in class for future serialization. returns. More...
 
void processDagBlocks (const PeriodData &block)
 Process Dag blocks and save stats in class for future serialization. returns. More...
 
void processDagBlocksAspen (const PeriodData &block)
 Process Dag blocks and save stats in class for future serialization with aspen HF changes. returns. More...
 
void initFeeByTrxHash (const SharedTransactions &transactions, const std::vector< gas_t > &trxs_gas_used)
 Prepare fee_by_trx_hash_ map with trx fee by trx hash. More...
 
bool addTransaction (const trx_hash_t &trx_hash, const addr_t &validator)
 In case unique trx_hash is provided, it is mapped to it's validator's address + validator's unique trxs count is incremented. If provided trx_hash was already processed, nothing happens. More...
 
bool addVote (const std::shared_ptr< PbftVote > &vote)
 In case unique vote is provided, author's votes weight is updated. If provided vote was already processed, nothing happens. More...
 

Class Documentation

◆ taraxa::rewards::BlockStats::ValidatorStats

struct taraxa::rewards::BlockStats::ValidatorStats
Class Members
uint32_t dag_blocks_count_
u256 fees_rewards_
uint64_t vote_weight_

Constructor & Destructor Documentation

◆ BlockStats() [1/2]

taraxa::rewards::BlockStats::BlockStats ( )
default

◆ BlockStats() [2/2]

taraxa::rewards::BlockStats::BlockStats ( const PeriodData block,
const std::vector< gas_t > &  trxs_gas_used,
uint64_t  dpos_vote_count,
uint32_t  committee_size,
const bool  aspen_dag_rewards = false 
)

setting block_author_, max_votes_weight_ and calls processStats function

Parameters
dpos_vote_count- votes count for previous block
committee_size
aspen_dag_rewards- aspen dag rewards

Member Function Documentation

◆ addTransaction()

bool taraxa::rewards::BlockStats::addTransaction ( const trx_hash_t trx_hash,
const addr_t validator 
)
private

In case unique trx_hash is provided, it is mapped to it's validator's address + validator's unique trxs count is incremented. If provided trx_hash was already processed, nothing happens.

Parameters
trx_hash
validator
Returns
true in case trx_hash was unique and processed, otherwise false

◆ addVote()

bool taraxa::rewards::BlockStats::addVote ( const std::shared_ptr< PbftVote > &  vote)
private

In case unique vote is provided, author's votes weight is updated. If provided vote was already processed, nothing happens.

Parameters
vote
Returns
true in case vote was unique and processed, otherwise false

◆ initFeeByTrxHash()

void taraxa::rewards::BlockStats::initFeeByTrxHash ( const SharedTransactions transactions,
const std::vector< gas_t > &  trxs_gas_used 
)
private

Prepare fee_by_trx_hash_ map with trx fee by trx hash.

Parameters
transactionscollection with transactions included in the block
trxs_gas_usedcollection with gas used by transactions

◆ processDagBlocks()

void taraxa::rewards::BlockStats::processDagBlocks ( const PeriodData block)
private

Process Dag blocks and save stats in class for future serialization. returns.

Parameters
block

◆ processDagBlocksAspen()

void taraxa::rewards::BlockStats::processDagBlocksAspen ( const PeriodData block)
private

Process Dag blocks and save stats in class for future serialization with aspen HF changes. returns.

Parameters
block

◆ processStats()

void taraxa::rewards::BlockStats::processStats ( const PeriodData block,
const bool  aspen_dag_rewards 
)
private

Process PeriodData and save stats in class for future serialization. returns.

Parameters
block
aspen_dag_rewards

Member Data Documentation

◆ block_author_

addr_t taraxa::rewards::BlockStats::block_author_
protected

◆ fee_by_trx_hash_

std::unordered_map<trx_hash_t, u256> taraxa::rewards::BlockStats::fee_by_trx_hash_
protected

◆ max_votes_weight_

uint64_t taraxa::rewards::BlockStats::max_votes_weight_ {0}
protected

◆ total_dag_blocks_count_

uint32_t taraxa::rewards::BlockStats::total_dag_blocks_count_ {0}
protected

◆ total_votes_weight_

uint64_t taraxa::rewards::BlockStats::total_votes_weight_ {0}
protected

◆ validators_stats_

std::unordered_map<addr_t, ValidatorStats> taraxa::rewards::BlockStats::validators_stats_
protected

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