Skip to content

Commit

Permalink
address rounding errors in fee calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
bytemaster committed Oct 1, 2015
1 parent 3bce5de commit 1137120
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libraries/chain/protocol/fee_schedule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,13 @@ namespace graphene { namespace chain {
auto scaled = fc::uint128(base_value) * scale;
scaled /= GRAPHENE_100_PERCENT;
FC_ASSERT( scaled <= GRAPHENE_MAX_SHARE_SUPPLY );
//idump( (base_value)(scaled)(core_exchange_rate) );
auto result = asset( scaled.to_uint64(), 0 ) * core_exchange_rate;
//FC_ASSERT( result * core_exchange_rate >= asset( scaled.to_uint64()) );

while( result * core_exchange_rate < asset( scaled.to_uint64()) )
result.amount++;

FC_ASSERT( result.amount <= GRAPHENE_MAX_SHARE_SUPPLY );
return result;
}
Expand Down

0 comments on commit 1137120

Please sign in to comment.