Skip to content

Commit

Permalink
fix available rewards computation after claim event
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill-K-1 committed Dec 2, 2024
1 parent ef8526e commit c2433f6
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions gov-portal-db/src/rewards_manager/rewards_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,16 @@ impl RewardsCache {
}
RewardsDelta::Claim(block_number, id, wallet) => {
unclaimed_rewards.entry(id).and_modify(|entry| {
entry.remove(&wallet);
});
let Some(claimed_reward) = entry.remove(&wallet) else {
return;
};

if let Some(available_reward) =
available_rewards_by_wallets.get_mut(&wallet)
{
available_reward.sub(available_reward.amount, block_number);
}
if let Some(available_reward) =
available_rewards_by_wallets.get_mut(&wallet)
{
available_reward.sub(claimed_reward.amount, block_number);
}
});
}
RewardsDelta::RevertBatch(block_number, id) => {
let Some(rewards_by_wallets) = unclaimed_rewards.remove(&id) else {
Expand Down

0 comments on commit c2433f6

Please sign in to comment.