Skip to content

Commit

Permalink
get block_reward data for possible ambassador block from last wallet …
Browse files Browse the repository at this point in the history
…block
  • Loading branch information
beuschl committed Apr 21, 2022
1 parent 514840a commit f686eff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/reward/src/reward/payout_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Payout_manager::Payout_manager(
, m_http_interface{ http_interface}
, m_shared_data_writer{ shared_data_writer }
, m_data_reader{ data_reader }
, m_current_avg_block_reward{0.0}
{
}

Expand All @@ -34,7 +35,6 @@ double Payout_manager::calculate_reward_of_blocks(std::uint32_t round, bool& cal
return 0.0;
}

double current_avg_block_reward = 0.0;
for (auto& block : blocks)
{
// all blocks which already have a reward for this round are filtered out
Expand Down Expand Up @@ -65,19 +65,14 @@ double Payout_manager::calculate_reward_of_blocks(std::uint32_t round, bool& cal


// check for ambassador blocks (blocks with very high mint which isn't credited to the pool)
if (reward_data.m_reward > 100.0)
if (reward_data.m_reward > 50.0)
{
if (current_avg_block_reward == 0.0)
{
current_avg_block_reward = 2.0; // TODO get this value dynamically from wallet
}

m_logger->warn("Ambassador block found with height {}. Cutting down block reward to {}", block.m_height, current_avg_block_reward);
reward_data.m_reward = current_avg_block_reward;
m_logger->warn("Ambassador block found with height {}. Cutting down block reward to {}", block.m_height, m_current_avg_block_reward);
reward_data.m_reward = m_current_avg_block_reward;
}
else
{
current_avg_block_reward = reward_data.m_reward;
m_current_avg_block_reward = reward_data.m_reward;
}

// update block in db
Expand Down
1 change: 1 addition & 0 deletions src/reward/src/reward/payout_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Payout_manager
persistance::Shared_data_writer& m_shared_data_writer;
persistance::Data_reader& m_data_reader;
std::uint32_t m_not_fully_paid_round;
double m_current_avg_block_reward;
};

}
Expand Down

0 comments on commit f686eff

Please sign in to comment.