TARAXA
taraxa::rewards::Stats Class Reference

class that is managing rewards stats processing and hardforks(intervals changes) So intermediate blocks stats are stored in the vector in data(to restore on the node restart) and full list of interval stats is returned in the end of interval More...

#include <rewards_stats.hpp>

Collaboration diagram for taraxa::rewards::Stats:

Public Member Functions

 Stats (uint32_t committee_size, const HardforksConfig &hardforks, std::shared_ptr< DbStorage > db, std::function< uint64_t(EthBlockNumber)> &&dpos_eligible_total_vote_count, EthBlockNumber last_blk_num=0)
 
std::vector< BlockStatsprocessStats (const PeriodData &current_blk, const std::vector< gas_t > &trxs_gas_used, Batch &write_batch)
 processing passed block and returns stats that should be processed at this block More...
 
void clear (uint64_t current_period)
 called on start of new rewards interval. clears blocks_stats_ collection and removes all data saved in db column More...
 

Protected Member Functions

void recoverFromDb (EthBlockNumber last_blk_num)
 recover current interval stats from database More...
 
uint32_t getCurrentDistributionFrequency (uint64_t current_period) const
 returns rewards distribution frequency for specified period More...
 
BlockStats getBlockStats (const PeriodData &current_blk, const std::vector< gas_t > &trxs_fees)
 
void saveBlockStats (uint64_t number, const BlockStats &stats, Batch &write_batch)
 saves stats to database to not lose this data in case of node restart More...
 

Protected Attributes

const uint32_t kCommitteeSize
 
const HardforksConfig kHardforksConfig
 
std::shared_ptr< DbStoragedb_
 
const std::function< uint64_t(EthBlockNumber)> dpos_eligible_total_vote_count_
 
std::unordered_map< PbftPeriod, BlockStatsblocks_stats_
 

Detailed Description

class that is managing rewards stats processing and hardforks(intervals changes) So intermediate blocks stats are stored in the vector in data(to restore on the node restart) and full list of interval stats is returned in the end of interval

Constructor & Destructor Documentation

◆ Stats()

taraxa::rewards::Stats::Stats ( uint32_t  committee_size,
const HardforksConfig hardforks,
std::shared_ptr< DbStorage db,
std::function< uint64_t(EthBlockNumber)> &&  dpos_eligible_total_vote_count,
EthBlockNumber  last_blk_num = 0 
)

Member Function Documentation

◆ clear()

void taraxa::rewards::Stats::clear ( uint64_t  current_period)

called on start of new rewards interval. clears blocks_stats_ collection and removes all data saved in db column

◆ getBlockStats()

BlockStats taraxa::rewards::Stats::getBlockStats ( const PeriodData current_blk,
const std::vector< gas_t > &  trxs_fees 
)
protected

◆ getCurrentDistributionFrequency()

uint32_t taraxa::rewards::Stats::getCurrentDistributionFrequency ( uint64_t  current_period) const
protected

returns rewards distribution frequency for specified period

◆ processStats()

std::vector< BlockStats > taraxa::rewards::Stats::processStats ( const PeriodData current_blk,
const std::vector< gas_t > &  trxs_gas_used,
Batch write_batch 
)

processing passed block and returns stats that should be processed at this block

Parameters
current_blkblock to process
Returns
vector<BlockStats> that should be processed at current block

◆ recoverFromDb()

void taraxa::rewards::Stats::recoverFromDb ( EthBlockNumber  last_blk_num)
protected

recover current interval stats from database

◆ saveBlockStats()

void taraxa::rewards::Stats::saveBlockStats ( uint64_t  number,
const BlockStats stats,
Batch write_batch 
)
protected

saves stats to database to not lose this data in case of node restart

Member Data Documentation

◆ blocks_stats_

std::unordered_map<PbftPeriod, BlockStats> taraxa::rewards::Stats::blocks_stats_
protected

◆ db_

std::shared_ptr<DbStorage> taraxa::rewards::Stats::db_
protected

◆ dpos_eligible_total_vote_count_

const std::function<uint64_t(EthBlockNumber)> taraxa::rewards::Stats::dpos_eligible_total_vote_count_
protected

◆ kCommitteeSize

const uint32_t taraxa::rewards::Stats::kCommitteeSize
protected

◆ kHardforksConfig

const HardforksConfig taraxa::rewards::Stats::kHardforksConfig
protected

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