From 1137120aa2198dc6c672bea7383da92b367c1a35 Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Thu, 1 Oct 2015 16:32:30 -0400 Subject: [PATCH] address rounding errors in fee calculation --- libraries/chain/protocol/fee_schedule.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libraries/chain/protocol/fee_schedule.cpp b/libraries/chain/protocol/fee_schedule.cpp index 05d9df993c..93f454a183 100644 --- a/libraries/chain/protocol/fee_schedule.cpp +++ b/libraries/chain/protocol/fee_schedule.cpp @@ -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; }