diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index c808a27c..ce056059 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -37,6 +37,7 @@ #include #include +#include #include #include #include diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 6b14f2bc..fa9677af 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -38,7 +38,6 @@ #include #include -#include #include diff --git a/libraries/chain/account_object.cpp b/libraries/chain/account_object.cpp index 71ee28de..30f3be14 100644 --- a/libraries/chain/account_object.cpp +++ b/libraries/chain/account_object.cpp @@ -36,10 +36,10 @@ share_type cut_fee(share_type a, uint16_t p) if( p == GRAPHENE_100_PERCENT ) return a; - fc::uint128 r(a.value); + fc::uint128_t r = a.value; r *= p; r /= GRAPHENE_100_PERCENT; - return r.to_uint64(); + return r.convert_to(); } void account_balance_object::adjust_balance(const asset& delta) diff --git a/libraries/chain/asset_object.cpp b/libraries/chain/asset_object.cpp index 79ad88ad..b074775a 100644 --- a/libraries/chain/asset_object.cpp +++ b/libraries/chain/asset_object.cpp @@ -38,10 +38,11 @@ share_type asset_bitasset_data_object::max_force_settlement_volume(share_type cu if( options.maximum_force_settlement_volume == GRAPHENE_100_PERCENT ) return current_supply + force_settled_volume; - fc::uint128 volume = current_supply.value + force_settled_volume.value; + fc::uint128_t volume = current_supply.value; + volume += force_settled_volume.value; volume *= options.maximum_force_settlement_volume; volume /= GRAPHENE_100_PERCENT; - return volume.to_uint64(); + return volume.convert_to(); } void asset_bitasset_data_object::update_median_feeds(time_point_sec current_time) diff --git a/libraries/chain/db_init.cpp b/libraries/chain/db_init.cpp index 9ae1fb96..c1fe2f0b 100644 --- a/libraries/chain/db_init.cpp +++ b/libraries/chain/db_init.cpp @@ -89,7 +89,6 @@ #include #include -#include #include #include @@ -614,7 +613,7 @@ void database::init_genesis(const genesis_state_type& genesis_state) p.time = genesis_state.initial_timestamp; p.dynamic_flags = 0; p.witness_budget = 0; - p.recent_slots_filled = fc::uint128::max_value(); + p.recent_slots_filled = std::numeric_limits::max(); }); create([&](global_betting_statistics_object& betting_statistics) { betting_statistics.number_of_active_events = 0; @@ -989,7 +988,7 @@ void database::init_genesis(const genesis_state_type& genesis_state) _wso.last_scheduling_block = 0; - _wso.recent_slots_filled = fc::uint128::max_value(); + _wso.recent_slots_filled = fc::uint128_t::max_value(); // for shuffled for( const witness_id_type& wid : get_global_properties().active_witnesses ) diff --git a/libraries/chain/db_maint.cpp b/libraries/chain/db_maint.cpp index 03d2a274..f56df81f 100644 --- a/libraries/chain/db_maint.cpp +++ b/libraries/chain/db_maint.cpp @@ -22,8 +22,6 @@ * THE SOFTWARE. */ -#include - #include #include @@ -184,10 +182,10 @@ void database::pay_workers( share_type& budget ) // Note: if there is a good chance that passed_time_count == day_count, // for better performance, can avoid the 128 bit calculation by adding a check. // Since it's not the case on BitShares mainnet, we're not using a check here. - fc::uint128 pay(requested_pay.value); + fc::uint128_t pay = requested_pay.value; pay *= passed_time_count; pay /= day_count; - requested_pay = pay.to_uint64(); + requested_pay = pay.convert_to(); share_type actual_pay = std::min(budget, requested_pay); //ilog(" ==> Paying ${a} to worker ${w}", ("w", active_worker.id)("a", actual_pay)); @@ -436,7 +434,7 @@ void database::initialize_budget_record( fc::time_point_sec now, budget_record& budget_u128 >>= GRAPHENE_CORE_ASSET_CYCLE_RATE_BITS; share_type budget; if( budget_u128 < reserve.value ) - rec.total_budget = share_type(budget_u128.to_uint64()); + rec.total_budget = share_type(budget_u128.convert_to()); else rec.total_budget = reserve; @@ -491,7 +489,7 @@ void database::process_budget() if( worker_budget_u128 >= available_funds.value ) worker_budget = available_funds; else - worker_budget = worker_budget_u128.to_uint64(); + worker_budget = worker_budget_u128.convert_to(); rec.worker_budget = worker_budget; available_funds -= worker_budget; @@ -631,12 +629,12 @@ void split_fba_balance( fc::uint128_t buyback_amount_128 = fba.accumulated_fba_fees.value; buyback_amount_128 *= designated_asset_buyback_pct; buyback_amount_128 /= GRAPHENE_100_PERCENT; - share_type buyback_amount = buyback_amount_128.to_uint64(); + share_type buyback_amount = buyback_amount_128.convert_to(); fc::uint128_t issuer_amount_128 = fba.accumulated_fba_fees.value; issuer_amount_128 *= designated_asset_issuer_pct; issuer_amount_128 /= GRAPHENE_100_PERCENT; - share_type issuer_amount = issuer_amount_128.to_uint64(); + share_type issuer_amount = issuer_amount_128.convert_to(); // this assert should never fail FC_ASSERT( buyback_amount + issuer_amount <= fba.accumulated_fba_fees ); diff --git a/libraries/chain/db_market.cpp b/libraries/chain/db_market.cpp index ad888532..49376f98 100644 --- a/libraries/chain/db_market.cpp +++ b/libraries/chain/db_market.cpp @@ -575,7 +575,7 @@ asset database::calculate_market_fee( const asset_object& trade_asset, const ass if( trade_asset.options.market_fee_percent == 0 ) return trade_asset.amount(0); - fc::uint128 a(trade_amount.amount.value); + fc::uint128_t a(trade_amount.amount.value); a *= trade_asset.options.market_fee_percent; a /= GRAPHENE_100_PERCENT; asset percent_fee = trade_asset.amount(a.to_uint64()); diff --git a/libraries/chain/db_update.cpp b/libraries/chain/db_update.cpp index 96f9e3ab..5703d04a 100644 --- a/libraries/chain/db_update.cpp +++ b/libraries/chain/db_update.cpp @@ -39,8 +39,6 @@ #include -#include - namespace graphene { namespace chain { void database::update_global_dynamic_data( const signed_block& b, const uint32_t missed_blocks ) diff --git a/libraries/chain/db_witness_schedule.cpp b/libraries/chain/db_witness_schedule.cpp index 762157bc..804fa46c 100644 --- a/libraries/chain/db_witness_schedule.cpp +++ b/libraries/chain/db_witness_schedule.cpp @@ -27,6 +27,8 @@ #include #include +#include + namespace graphene { namespace chain { using boost::container::flat_set; diff --git a/libraries/chain/evaluator.cpp b/libraries/chain/evaluator.cpp index 2ae8f0e7..d92564e9 100644 --- a/libraries/chain/evaluator.cpp +++ b/libraries/chain/evaluator.cpp @@ -35,8 +35,6 @@ #include #include -#include - namespace graphene { namespace chain { database& generic_evaluator::db()const { return trx_state->db(); } diff --git a/libraries/chain/genesis_state.cpp b/libraries/chain/genesis_state.cpp index 53311012..7e67180d 100644 --- a/libraries/chain/genesis_state.cpp +++ b/libraries/chain/genesis_state.cpp @@ -28,6 +28,8 @@ #include // required for gcc in release mode #include +#include + namespace graphene { namespace chain { chain_id_type genesis_state_type::compute_chain_id() const diff --git a/libraries/chain/include/graphene/chain/global_property_object.hpp b/libraries/chain/include/graphene/chain/global_property_object.hpp index 0ed401a1..789b1bd1 100644 --- a/libraries/chain/include/graphene/chain/global_property_object.hpp +++ b/libraries/chain/include/graphene/chain/global_property_object.hpp @@ -84,8 +84,6 @@ namespace graphene { namespace chain { * every time a block is found it decreases by * RECENTLY_MISSED_COUNT_DECREMENT. It is * never less than 0. - * - * If the recently_missed_count hits 2*UNDO_HISTORY then no new blocks may be pushed. */ uint32_t recently_missed_count = 0; diff --git a/libraries/chain/include/graphene/chain/protocol/types.hpp b/libraries/chain/include/graphene/chain/protocol/types.hpp index 6fa2ab4d..f141b078 100644 --- a/libraries/chain/include/graphene/chain/protocol/types.hpp +++ b/libraries/chain/include/graphene/chain/protocol/types.hpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include diff --git a/libraries/chain/include/graphene/chain/vesting_balance_object.hpp b/libraries/chain/include/graphene/chain/vesting_balance_object.hpp index b03b8f7b..19acc0e7 100644 --- a/libraries/chain/include/graphene/chain/vesting_balance_object.hpp +++ b/libraries/chain/include/graphene/chain/vesting_balance_object.hpp @@ -89,11 +89,11 @@ namespace graphene { namespace chain { */ struct cdd_vesting_policy { - uint32_t vesting_seconds = 0; - fc::uint128_t coin_seconds_earned; + uint32_t vesting_seconds = 0; + fc::uint128_t coin_seconds_earned; /** while coindays may accrue over time, none may be claimed before first_claim date */ - fc::time_point_sec start_claim; - fc::time_point_sec coin_seconds_earned_last_update; + fc::time_point_sec start_claim; + fc::time_point_sec coin_seconds_earned_last_update; /** * Compute coin_seconds_earned. Used to diff --git a/libraries/chain/market_evaluator.cpp b/libraries/chain/market_evaluator.cpp index 60e07669..2ffb1f1d 100644 --- a/libraries/chain/market_evaluator.cpp +++ b/libraries/chain/market_evaluator.cpp @@ -34,7 +34,6 @@ #include -#include #include namespace graphene { namespace chain { diff --git a/libraries/chain/protocol/asset.cpp b/libraries/chain/protocol/asset.cpp index 525e193b..ebff3518 100644 --- a/libraries/chain/protocol/asset.cpp +++ b/libraries/chain/protocol/asset.cpp @@ -25,6 +25,7 @@ #include #include #include +#include namespace graphene { namespace chain { typedef boost::multiprecision::uint128_t uint128_t; diff --git a/libraries/chain/protocol/fee_schedule.cpp b/libraries/chain/protocol/fee_schedule.cpp index 6d494e37..dd0a1a3d 100644 --- a/libraries/chain/protocol/fee_schedule.cpp +++ b/libraries/chain/protocol/fee_schedule.cpp @@ -36,6 +36,7 @@ namespace fc } #include +#include #define MAX_FEE_STABILIZATION_ITERATION 4 @@ -131,7 +132,7 @@ namespace graphene { namespace chain { auto itr = parameters.find(params); if( itr != parameters.end() ) params = *itr; auto base_value = op.visit( calc_fee_visitor( params ) ); - auto scaled = fc::uint128(base_value) * scale; + auto scaled = fc::uint128_t(base_value) * scale; scaled /= GRAPHENE_100_PERCENT; FC_ASSERT( scaled <= GRAPHENE_MAX_SHARE_SUPPLY ); //idump( (base_value)(scaled)(core_exchange_rate) ); diff --git a/libraries/chain/protocol/operations.cpp b/libraries/chain/protocol/operations.cpp index 7db51078..7ec951f2 100644 --- a/libraries/chain/protocol/operations.cpp +++ b/libraries/chain/protocol/operations.cpp @@ -25,14 +25,15 @@ #include #include #include +#include namespace graphene { namespace chain { uint64_t base_operation::calculate_data_fee( uint64_t bytes, uint64_t price_per_kbyte ) { - auto result = (fc::uint128(bytes) * price_per_kbyte) / 1024; + auto result = (fc::uint128_t(bytes) * price_per_kbyte) / 1024; FC_ASSERT( result <= GRAPHENE_MAX_SHARE_SUPPLY ); - return result.to_uint64(); + return result.convert_to(); } void balance_claim_operation::validate()const diff --git a/libraries/chain/vesting_balance_object.cpp b/libraries/chain/vesting_balance_object.cpp index 4674c974..b9e99ae9 100644 --- a/libraries/chain/vesting_balance_object.cpp +++ b/libraries/chain/vesting_balance_object.cpp @@ -127,7 +127,7 @@ asset cdd_vesting_policy::get_allowed_withdraw(const vesting_policy_context& ctx fc::uint128_t cs_earned = compute_coin_seconds_earned(ctx); fc::uint128_t withdraw_available = cs_earned / std::max(vesting_seconds, 1u); assert(withdraw_available <= ctx.balance.amount.value); - return asset(withdraw_available.to_uint64(), ctx.balance.asset_id); + return asset(static_cast(withdraw_available), ctx.balance.asset_id); } void cdd_vesting_policy::on_deposit(const vesting_policy_context& ctx) diff --git a/libraries/db/include/graphene/db/generic_index.hpp b/libraries/db/include/graphene/db/generic_index.hpp index 10e5d19e..2f760ee2 100644 --- a/libraries/db/include/graphene/db/generic_index.hpp +++ b/libraries/db/include/graphene/db/generic_index.hpp @@ -33,7 +33,7 @@ namespace graphene { namespace chain { using boost::multi_index_container; using namespace boost::multi_index; - struct by_id{}; + struct by_id; /** * Almost all objects can be tracked and managed via a boost::multi_index container that uses * an unordered_unique key on the object ID. This template class adapts the generic index interface @@ -112,18 +112,7 @@ namespace graphene { namespace chain { const index_type& indices()const { return _indices; } - virtual fc::uint128 hash()const override { - fc::uint128 result; - for( const auto& ptr : _indices ) - { - result += ptr.hash(); - } - - return result; - } - private: - fc::uint128 _current_hash; index_type _indices; }; diff --git a/libraries/db/include/graphene/db/index.hpp b/libraries/db/include/graphene/db/index.hpp index 1bc593f4..6a6fb3f1 100644 --- a/libraries/db/include/graphene/db/index.hpp +++ b/libraries/db/include/graphene/db/index.hpp @@ -129,7 +129,6 @@ namespace graphene { namespace db { } virtual void inspect_all_objects(std::function inspector)const = 0; - virtual fc::uint128 hash()const = 0; virtual void add_observer( const shared_ptr& ) = 0; virtual void object_from_variant( const fc::variant& var, object& obj, uint32_t max_depth )const = 0; diff --git a/libraries/db/include/graphene/db/object.hpp b/libraries/db/include/graphene/db/object.hpp index c410e273..09734d5f 100644 --- a/libraries/db/include/graphene/db/object.hpp +++ b/libraries/db/include/graphene/db/object.hpp @@ -23,9 +23,9 @@ */ #pragma once #include +#include #include #include -#include #define MAX_NESTING (200) @@ -77,7 +77,6 @@ namespace graphene { namespace db { virtual void move_from( object& obj ) = 0; virtual variant to_variant()const = 0; virtual vector pack()const = 0; - virtual fc::uint128 hash()const = 0; }; /** @@ -102,10 +101,6 @@ namespace graphene { namespace db { } virtual variant to_variant()const { return variant( static_cast(*this), MAX_NESTING ); } virtual vector pack()const { return fc::raw::pack( static_cast(*this) ); } - virtual fc::uint128 hash()const { - auto tmp = this->pack(); - return fc::city_hash_crc_128( tmp.data(), tmp.size() ); - } }; typedef flat_map annotation_map; @@ -139,6 +134,13 @@ namespace graphene { namespace db { } } // graphene::db +// Without this, pack(object_id) tries to match the template for +// pack(boost::multiprecision::uint128_t). No idea why. :-( +namespace boost { namespace multiprecision { namespace detail { +template +struct is_restricted_conversion : public mpl::true_ {}; +}}} + FC_REFLECT_TYPENAME( graphene::db::annotation_map ) FC_REFLECT( graphene::db::object, (id) ) FC_REFLECT_DERIVED_TEMPLATE( (typename Derived), graphene::db::annotated_object, (graphene::db::object), (annotations) ) diff --git a/libraries/db/include/graphene/db/simple_index.hpp b/libraries/db/include/graphene/db/simple_index.hpp index 0e807aef..51679be2 100644 --- a/libraries/db/include/graphene/db/simple_index.hpp +++ b/libraries/db/include/graphene/db/simple_index.hpp @@ -98,13 +98,6 @@ namespace graphene { namespace db { } } FC_CAPTURE_AND_RETHROW() } - virtual fc::uint128 hash()const override { - fc::uint128 result; - for( const auto& ptr : _objects ) - result += ptr->hash(); - - return result; - } class const_iterator { diff --git a/libraries/db/object_database.cpp b/libraries/db/object_database.cpp index fdde0fed..7e67c926 100644 --- a/libraries/db/object_database.cpp +++ b/libraries/db/object_database.cpp @@ -25,7 +25,6 @@ #include #include -#include namespace graphene { namespace db { diff --git a/libraries/fc b/libraries/fc index 9fa98d9a..69ebbf4b 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 9fa98d9a93ada3e84f48812b5c42b053b0dbf9da +Subproject commit 69ebbf4ba490482956de0e331b22f1018747d789 diff --git a/libraries/plugins/market_history/include/graphene/market_history/market_history_plugin.hpp b/libraries/plugins/market_history/include/graphene/market_history/market_history_plugin.hpp index b4d1254c..ad56e557 100644 --- a/libraries/plugins/market_history/include/graphene/market_history/market_history_plugin.hpp +++ b/libraries/plugins/market_history/include/graphene/market_history/market_history_plugin.hpp @@ -123,7 +123,6 @@ typedef multi_index_container< > > order_history_multi_index_type; - typedef generic_index bucket_index; typedef generic_index history_index; diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 97b31370..1846cb13 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -62,7 +62,13 @@ #include #include #include +<<<<<<< HEAD #include +======= +#include +#include +#include +>>>>>>> 8f1eca14... Replace fc::uint128 with boost::multiprecision::uint128_t #include #include @@ -680,7 +686,13 @@ public: " old"); result["next_maintenance_time"] = fc::get_approximate_relative_time_string(dynamic_props.next_maintenance_time); result["chain_id"] = chain_props.chain_id; +<<<<<<< HEAD result["participation"] = (100*dynamic_props.recent_slots_filled.popcount()) / 128.0; +======= + stringstream participation; + participation << fixed << std::setprecision(2) << (100.0*fc::popcount(dynamic_props.recent_slots_filled)) / 128.0; + result["participation"] = participation.str(); +>>>>>>> 8f1eca14... Replace fc::uint128 with boost::multiprecision::uint128_t result["active_witnesses"] = fc::variant(global_props.active_witnesses, GRAPHENE_MAX_NESTED_OBJECTS); result["active_committee_members"] = fc::variant(global_props.active_committee_members, GRAPHENE_MAX_NESTED_OBJECTS); result["entropy"] = fc::variant(dynamic_props.random, GRAPHENE_MAX_NESTED_OBJECTS); diff --git a/tests/tests/block_tests.cpp b/tests/tests/block_tests.cpp index b7ed69fe..60e25eff 100644 --- a/tests/tests/block_tests.cpp +++ b/tests/tests/block_tests.cpp @@ -1030,9 +1030,9 @@ BOOST_FIXTURE_TEST_CASE( rsf_missed_blocks, database_fixture ) { generate_block(); - auto rsf = [&]() -> string + auto rsf = [this]() -> string { - fc::uint128 rsf; + fc::uint128_t rsf; if (db.get_global_properties().parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SCHEDULED_ALGORITHM) rsf = db.get(witness_schedule_id_type()).recent_slots_filled; else @@ -1041,7 +1041,7 @@ BOOST_FIXTURE_TEST_CASE( rsf_missed_blocks, database_fixture ) result.reserve(128); for( int i=0; i<128; i++ ) { - result += ((rsf.lo & 1) == 0) ? '0' : '1'; + result += rsf & 1 ? '1' : '0'; rsf >>= 1; } return result; diff --git a/tests/tests/fee_tests.cpp b/tests/tests/fee_tests.cpp index 96494899..5d16dc72 100644 --- a/tests/tests/fee_tests.cpp +++ b/tests/tests/fee_tests.cpp @@ -35,6 +35,8 @@ #include #include +#include + #include #include "../common/database_fixture.hpp" @@ -245,7 +247,7 @@ uint64_t pct( uint64_t percentage, uint64_t val ) fc::uint128_t x = percentage; x *= val; x /= GRAPHENE_100_PERCENT; - return x.to_uint64(); + return static_cast(x); } uint64_t pct( uint64_t percentage0, uint64_t percentage1, uint64_t val )