Skip to content

Commit

Permalink
fix: avoid float calculations in PlatformShare
Browse files Browse the repository at this point in the history
  • Loading branch information
UdjinM6 committed Oct 6, 2023
1 parent c814dca commit dcd3b27
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/masternode/payments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,9 @@ void FillBlockPayments(const CSporkManager& sporkManager, CGovernanceManager& go

CAmount PlatformShare(const CAmount reward)
{
constexpr double platformShare = 0.375;
const CAmount platformReward = reward * platformShare;
assert(MoneyRange(platformReward));

const CAmount platformReward = reward * 375 / 1000;
bool ok = MoneyRange(platformReward);
assert(ok);
return platformReward;
}

Expand Down
2 changes: 1 addition & 1 deletion test/functional/feature_asset_locks.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ def run_test(self):
all_mn_rewards = platform_reward + owner_reward + operator_reward
all_mn_rewards += 1 * 0.75
assert_equal(all_mn_rewards, bt['coinbasevalue'] * 0.75) # 75/25 mn/miner reward split
assert_equal(platform_reward, int(all_mn_rewards * 0.375)) # 0.375 platform share
assert_equal(platform_reward, int(all_mn_rewards * 375 // 1000)) # 0.375 platform share
assert_equal(platform_reward, 2555399792)
assert_equal(new_total, self.get_credit_pool_balance())
node.generate(1)
Expand Down

0 comments on commit dcd3b27

Please sign in to comment.