mirror of
https://github.com/monero-project/monero.git
synced 2025-08-08 12:12:24 -04:00
blockchain: use effective median block weight for penalty from v12
It was using the raw block weight median, which was not what was intended in ArticMine's design
This commit is contained in:
parent
bf525793c7
commit
ab96181e91
2 changed files with 13 additions and 3 deletions
|
@ -1176,9 +1176,18 @@ bool Blockchain::validate_miner_transaction(const block& b, size_t cumulative_bl
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<uint64_t> last_blocks_weights;
|
||||
get_last_n_blocks_weights(last_blocks_weights, CRYPTONOTE_REWARD_BLOCKS_WINDOW);
|
||||
if (!get_block_reward(epee::misc_utils::median(last_blocks_weights), cumulative_block_weight, already_generated_coins, base_reward, version))
|
||||
uint64_t median_weight;
|
||||
if (version >= HF_VERSION_EFFECTIVE_SHORT_TERM_MEDIAN_IN_PENALTY)
|
||||
{
|
||||
median_weight = m_current_block_cumul_weight_median;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<uint64_t> last_blocks_weights;
|
||||
get_last_n_blocks_weights(last_blocks_weights, CRYPTONOTE_REWARD_BLOCKS_WINDOW);
|
||||
median_weight = epee::misc_utils::median(last_blocks_weights);
|
||||
}
|
||||
if (!get_block_reward(median_weight, cumulative_block_weight, already_generated_coins, base_reward, version))
|
||||
{
|
||||
MERROR_VER("block weight " << cumulative_block_weight << " is bigger than allowed for this blockchain");
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue