From 95532b30c09eae691e6a2bc599ea3a06fd67be34 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Sat, 23 Mar 2019 11:34:34 -0500 Subject: [PATCH 1/5] Resolve #1670: Make const const again --- libraries/app/application.cpp | 2 +- libraries/chain/account_evaluator.cpp | 2 +- libraries/chain/db_getter.cpp | 2 +- libraries/chain/db_init.cpp | 4 +- libraries/chain/db_maint.cpp | 2 +- .../chain/protocol/chain_parameters.hpp | 7 +- .../graphene/chain/protocol/fee_schedule.hpp | 4 - .../include/graphene/chain/protocol/types.hpp | 17 +++ libraries/chain/protocol/fee_schedule.cpp | 2 +- libraries/chain/protocol/types.cpp | 10 ++ libraries/egenesis/embed_genesis.cpp | 4 +- libraries/fc | 2 +- libraries/net/node.cpp | 3 + libraries/wallet/wallet.cpp | 104 +++++++++--------- tests/common/database_fixture.cpp | 12 +- tests/tests/block_tests.cpp | 2 +- tests/tests/fee_tests.cpp | 24 ++-- tests/tests/operation_tests.cpp | 6 +- tests/tests/uia_tests.cpp | 2 +- 19 files changed, 119 insertions(+), 92 deletions(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index cc3941b50a..b0b446e350 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -81,7 +81,7 @@ namespace detail { auto nathan_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("nathan"))); dlog("Allocating all stake to ${key}", ("key", utilities::key_to_wif(nathan_key))); graphene::chain::genesis_state_type initial_state; - initial_state.initial_parameters.current_fees = std::make_shared(fee_schedule::get_default()); + initial_state.initial_parameters.get_current_fees() = fee_schedule::get_default(); initial_state.initial_active_witnesses = GRAPHENE_DEFAULT_MIN_WITNESS_COUNT; initial_state.initial_timestamp = time_point_sec(time_point::now().sec_since_epoch() / initial_state.initial_parameters.block_interval * diff --git a/libraries/chain/account_evaluator.cpp b/libraries/chain/account_evaluator.cpp index 98e0766652..da55e54ff6 100644 --- a/libraries/chain/account_evaluator.cpp +++ b/libraries/chain/account_evaluator.cpp @@ -240,7 +240,7 @@ object_id_type account_create_evaluator::do_apply( const account_create_operatio && global_properties.parameters.account_fee_scale_bitshifts != 0 ) { d.modify(global_properties, [](global_property_object& p) { - p.parameters.current_fees->get().basic_fee <<= p.parameters.account_fee_scale_bitshifts; + p.parameters.get_current_fees().get().basic_fee <<= p.parameters.account_fee_scale_bitshifts; }); } diff --git a/libraries/chain/db_getter.cpp b/libraries/chain/db_getter.cpp index eea3e7ebb8..3a4ff98c18 100644 --- a/libraries/chain/db_getter.cpp +++ b/libraries/chain/db_getter.cpp @@ -57,7 +57,7 @@ const dynamic_global_property_object& database::get_dynamic_global_properties() const fee_schedule& database::current_fee_schedule()const { - return *get_global_properties().parameters.current_fees; + return get_global_properties().parameters.get_current_fees(); } time_point_sec database::head_block_time()const diff --git a/libraries/chain/db_init.cpp b/libraries/chain/db_init.cpp index 36e19f2ac5..d8def12e50 100644 --- a/libraries/chain/db_init.cpp +++ b/libraries/chain/db_init.cpp @@ -422,7 +422,7 @@ void database::init_genesis(const genesis_state_type& genesis_state) p.parameters = genesis_state.initial_parameters; // Set fees to zero initially, so that genesis initialization needs not pay them // We'll fix it at the end of the function - p.parameters.current_fees->zero_all_fees(); + p.parameters.get_current_fees().zero_all_fees(); }); _p_dyn_global_prop_obj = & create([&genesis_state](dynamic_global_property_object& p) { @@ -692,7 +692,7 @@ void database::init_genesis(const genesis_state_type& genesis_state) // Enable fees modify(get_global_properties(), [&genesis_state](global_property_object& p) { - p.parameters.current_fees = genesis_state.initial_parameters.current_fees; + p.parameters.get_current_fees() = genesis_state.initial_parameters.get_current_fees(); }); // Create witness scheduler diff --git a/libraries/chain/db_maint.cpp b/libraries/chain/db_maint.cpp index 446d8516c0..ba045a1b10 100644 --- a/libraries/chain/db_maint.cpp +++ b/libraries/chain/db_maint.cpp @@ -1236,7 +1236,7 @@ void database::perform_chain_maintenance(const signed_block& next_block, const g modify(gpo, [&dgpo](global_property_object& p) { // Remove scaling of account registration fee - p.parameters.current_fees->get().basic_fee >>= p.parameters.account_fee_scale_bitshifts * + p.parameters.get_current_fees().get().basic_fee >>= p.parameters.account_fee_scale_bitshifts * (dgpo.accounts_registered_this_interval / p.parameters.accounts_per_fee_scale); if( p.pending_parameters ) diff --git a/libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp b/libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp index 1d919cc8f3..d9e5affea6 100644 --- a/libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp +++ b/libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp @@ -34,12 +34,13 @@ namespace graphene { namespace chain { uint32_t max_preimage_size; }; - struct fee_schedule; - struct chain_parameters { /** using a shared_ptr breaks the circular dependency created between operations and the fee schedule */ - std::shared_ptr current_fees; ///< current schedule of fees + std::shared_ptr current_fees; ///< current schedule of fees + const fee_schedule& get_current_fees() const { FC_ASSERT(current_fees); return *current_fees; } + fee_schedule& get_current_fees() { FC_ASSERT(current_fees); return const_cast(*current_fees); } + uint8_t block_interval = GRAPHENE_DEFAULT_BLOCK_INTERVAL; ///< interval in seconds between blocks uint32_t maintenance_interval = GRAPHENE_DEFAULT_MAINTENANCE_INTERVAL; ///< interval in sections between blockchain maintenance events uint8_t maintenance_skip_slots = GRAPHENE_DEFAULT_MAINTENANCE_SKIP_SLOTS; ///< number of block_intervals to skip at maintenance time diff --git a/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp b/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp index 914044486b..0b22c53c7c 100644 --- a/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp +++ b/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp @@ -209,9 +209,5 @@ namespace graphene { namespace chain { } } // graphene::chain -namespace fc { - template<> struct get_typename> { static const char* name() { return "shared_ptr"; } }; -} - FC_REFLECT_TYPENAME( graphene::chain::fee_parameters ) FC_REFLECT( graphene::chain::fee_schedule, (parameters)(scale) ) diff --git a/libraries/chain/include/graphene/chain/protocol/types.hpp b/libraries/chain/include/graphene/chain/protocol/types.hpp index 5edfb747c7..35b1c88a14 100644 --- a/libraries/chain/include/graphene/chain/protocol/types.hpp +++ b/libraries/chain/include/graphene/chain/protocol/types.hpp @@ -334,6 +334,9 @@ namespace graphene { namespace chain { friend bool operator == ( const extended_private_key_type& p1, const extended_private_key_type& p2); friend bool operator != ( const extended_private_key_type& p1, const extended_private_key_type& p2); }; + + // Forward-declare fee_schedule to allow typename reflection below + struct fee_schedule; } } // graphene::chain namespace fc @@ -344,7 +347,21 @@ namespace fc void from_variant( const fc::variant& var, graphene::chain::extended_public_key_type& vo, uint32_t max_depth = 2 ); void to_variant( const graphene::chain::extended_private_key_type& var, fc::variant& vo, uint32_t max_depth = 2 ); void from_variant( const fc::variant& var, graphene::chain::extended_private_key_type& vo, uint32_t max_depth = 2 ); + + // Define typename reflectors for shared_ptr here, so they're available everywhere that needs them + // (Cannot be done in fee_schedule.hpp because chain_parameters.hpp forward declares fee_schedule to make a shared_ptr to one) + template<> struct get_typename> { static const char* name() { + return "shared_ptr"; + } }; + template<> struct get_typename> { static const char* name() { + return "shared_ptr"; + } }; + void from_variant( const fc::variant& var, std::shared_ptr& vo, + uint32_t max_depth = 2 ); } +namespace fc { +} + FC_REFLECT( graphene::chain::public_key_type, (key_data) ) FC_REFLECT( graphene::chain::public_key_type::binary_key, (data)(check) ) diff --git a/libraries/chain/protocol/fee_schedule.cpp b/libraries/chain/protocol/fee_schedule.cpp index 24efe2ce8c..2be3952585 100644 --- a/libraries/chain/protocol/fee_schedule.cpp +++ b/libraries/chain/protocol/fee_schedule.cpp @@ -158,7 +158,7 @@ namespace graphene { namespace chain { void chain_parameters::validate()const { - current_fees->validate(); + get_current_fees().validate(); FC_ASSERT( reserve_percent_of_fee <= GRAPHENE_100_PERCENT ); FC_ASSERT( network_percent_of_fee <= GRAPHENE_100_PERCENT ); FC_ASSERT( lifetime_referrer_percent_of_fee <= GRAPHENE_100_PERCENT ); diff --git a/libraries/chain/protocol/types.cpp b/libraries/chain/protocol/types.cpp index a51474f0da..4ca33e6f64 100644 --- a/libraries/chain/protocol/types.cpp +++ b/libraries/chain/protocol/types.cpp @@ -23,6 +23,7 @@ */ #include #include +#include #include #include @@ -229,4 +230,13 @@ namespace fc { vo = graphene::chain::extended_private_key_type( var.as_string() ); } + + void from_variant( const fc::variant& var, std::shared_ptr& vo, + uint32_t max_depth ) { + // If it's null, just make a new one + if (!vo) vo = std::make_shared(); + // Convert the non-const shared_ptr to a non-const fee_schedule& so we can write it + // Don't decrement max_depth since we're not actually deserializing at this step + from_variant(var, const_cast(*vo), max_depth); + } } // fc diff --git a/libraries/egenesis/embed_genesis.cpp b/libraries/egenesis/embed_genesis.cpp index 6854e9f6d3..d88d43b6ec 100644 --- a/libraries/egenesis/embed_genesis.cpp +++ b/libraries/egenesis/embed_genesis.cpp @@ -217,7 +217,7 @@ void load_genesis( } int main( int argc, char** argv ) -{ +{ try { int main_return = 0; boost::program_options::options_description cli_options("Graphene Chain Identifier"); cli_options.add_options() @@ -285,4 +285,4 @@ int main( int argc, char** argv ) } return main_return; -} +} catch( fc::exception& e ) { edump((e)); throw; } } diff --git a/libraries/fc b/libraries/fc index 1a411b813a..a0ca5ab29d 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 1a411b813a61f12587234d1bb5f32ad1a95883a9 +Subproject commit a0ca5ab29d259cc027920fd342a86e943157574a diff --git a/libraries/net/node.cpp b/libraries/net/node.cpp index b2fc5009b7..ed86b7a01e 100644 --- a/libraries/net/node.cpp +++ b/libraries/net/node.cpp @@ -78,6 +78,9 @@ #include #include +// Nasty hack: A circular dependency around fee_schedule is resolved by fwd-declaring it and using a shared_ptr +// to it in chain_parameters, which is used in an operation and thus must be serialized by the net library. +// Resolving that forward declaration doesn't happen until now: #include #include diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index a82345a308..f994cb4a0d 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -539,10 +539,10 @@ class wallet_api_impl return ob.template as( GRAPHENE_MAX_NESTED_OBJECTS ); } - void set_operation_fees( signed_transaction& tx, const std::shared_ptr s ) + void set_operation_fees( signed_transaction& tx, const fee_schedule& s ) { for( auto& op : tx.operations ) - s->set_fee(op); + s.set_fee(op); } variant info() const @@ -1004,7 +1004,7 @@ class wallet_api_impl if( fee_asset_obj.get_id() != asset_id_type() ) { for( auto& op : _builder_transactions[handle].operations ) - total_fee += gprops.current_fees->set_fee( op, fee_asset_obj.options.core_exchange_rate ); + total_fee += gprops.get_current_fees().set_fee( op, fee_asset_obj.options.core_exchange_rate ); FC_ASSERT((total_fee * fee_asset_obj.options.core_exchange_rate).amount <= get_object(fee_asset_obj.dynamic_asset_data_id).fee_pool, @@ -1012,7 +1012,7 @@ class wallet_api_impl ("asset", fee_asset_obj.symbol)); } else { for( auto& op : _builder_transactions[handle].operations ) - total_fee += gprops.current_fees->set_fee( op ); + total_fee += gprops.get_current_fees().set_fee( op ); } return total_fee; @@ -1055,7 +1055,7 @@ class wallet_api_impl if( review_period_seconds ) op.review_period_seconds = review_period_seconds; trx.operations = {op}; - _remote_db->get_global_properties().parameters.current_fees->set_fee( trx.operations.front() ); + _remote_db->get_global_properties().parameters.get_current_fees().set_fee( trx.operations.front() ); return trx = sign_transaction(trx, broadcast); } @@ -1076,7 +1076,7 @@ class wallet_api_impl if( review_period_seconds ) op.review_period_seconds = review_period_seconds; trx.operations = {op}; - _remote_db->get_global_properties().parameters.current_fees->set_fee( trx.operations.front() ); + _remote_db->get_global_properties().parameters.get_current_fees().set_fee( trx.operations.front() ); return trx = sign_transaction(trx, broadcast); } @@ -1125,7 +1125,7 @@ class wallet_api_impl tx.operations.push_back( account_create_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees() ); vector paying_keys = registrar_account_object.active.get_keys(); @@ -1164,7 +1164,7 @@ class wallet_api_impl op.account_to_upgrade = account_obj.get_id(); op.upgrade_to_lifetime_member = true; tx.operations = {op}; - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees() ); tx.validate(); return sign_transaction( tx, broadcast ); @@ -1249,7 +1249,7 @@ class wallet_api_impl tx.operations.push_back( account_create_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); vector paying_keys = registrar_account_object.active.get_keys(); @@ -1314,7 +1314,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( create_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -1345,7 +1345,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( update_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -1368,7 +1368,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( update_issuer ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -1389,7 +1389,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( update_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -1413,7 +1413,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( update_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -1435,7 +1435,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( publish_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -1459,7 +1459,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( fund_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -1481,7 +1481,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( claim_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -1504,7 +1504,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( reserve_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -1525,7 +1525,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( settle_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -1546,7 +1546,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( settle_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -1571,7 +1571,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -1589,7 +1589,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( whitelist_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -1615,7 +1615,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( committee_member_create_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -1710,7 +1710,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( witness_create_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); _wallet.pending_witness_registrations[owner_account] = key_to_wif(witness_private_key); @@ -1736,7 +1736,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( witness_update_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees() ); tx.validate(); return sign_transaction( tx, broadcast ); @@ -1787,7 +1787,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees() ); tx.validate(); return sign_transaction( tx, broadcast ); @@ -1851,7 +1851,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( update_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees() ); tx.validate(); return sign_transaction( tx, broadcast ); @@ -2000,7 +2000,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( vesting_balance_withdraw_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees() ); tx.validate(); return sign_transaction( tx, broadcast ); @@ -2042,7 +2042,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( account_update_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -2083,7 +2083,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( account_update_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -2114,7 +2114,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( account_update_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -2140,7 +2140,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( account_update_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -2285,7 +2285,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(op); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -2306,7 +2306,7 @@ class wallet_api_impl signed_transaction trx; trx.operations = {op}; - set_operation_fees( trx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( trx, _remote_db->get_global_properties().parameters.get_current_fees()); trx.validate(); return sign_transaction(trx, broadcast); @@ -2330,7 +2330,7 @@ class wallet_api_impl signed_transaction trx; trx.operations = {op}; - set_operation_fees( trx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( trx, _remote_db->get_global_properties().parameters.get_current_fees()); trx.validate(); return sign_transaction(trx, broadcast); @@ -2346,7 +2346,7 @@ class wallet_api_impl op.fee_paying_account = get_object(order_id).seller; op.order = order_id; trx.operations = {op}; - set_operation_fees( trx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( trx, _remote_db->get_global_properties().parameters.get_current_fees()); trx.validate(); return sign_transaction(trx, broadcast); @@ -2381,7 +2381,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(xfer_op); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); @@ -2411,7 +2411,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(issue_op); - set_operation_fees(tx,_remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(tx,_remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); @@ -2681,11 +2681,11 @@ class wallet_api_impl prop_op.fee_paying_account = get_account(proposing_account).id; prop_op.proposed_ops.emplace_back( update_op ); - current_params.current_fees->set_fee( prop_op.proposed_ops.back().op ); + current_params.get_current_fees().set_fee( prop_op.proposed_ops.back().op ); signed_transaction tx; tx.operations.push_back(prop_op); - set_operation_fees(tx, current_params.current_fees); + set_operation_fees(tx, current_params.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); @@ -2698,7 +2698,7 @@ class wallet_api_impl bool broadcast = false) { const chain_parameters& current_params = get_global_properties().parameters; - const fee_schedule_type& current_fees = *(current_params.current_fees); + const fee_schedule_type& current_fees = current_params.get_current_fees(); flat_map< int, fee_parameters > fee_map; fee_map.reserve( current_fees.parameters.size() ); @@ -2751,7 +2751,7 @@ class wallet_api_impl new_fees.scale = scale; chain_parameters new_params = current_params; - new_params.current_fees = std::make_shared(new_fees); + new_params.get_current_fees() = new_fees; committee_member_update_global_parameters_operation update_op; update_op.new_parameters = new_params; @@ -2763,11 +2763,11 @@ class wallet_api_impl prop_op.fee_paying_account = get_account(proposing_account).id; prop_op.proposed_ops.emplace_back( update_op ); - current_params.current_fees->set_fee( prop_op.proposed_ops.back().op ); + current_params.get_current_fees().set_fee( prop_op.proposed_ops.back().op ); signed_transaction tx; tx.operations.push_back(prop_op); - set_operation_fees(tx, current_params.current_fees); + set_operation_fees(tx, current_params.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); @@ -2801,7 +2801,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(update_op); - set_operation_fees(tx, get_global_properties().parameters.current_fees); + set_operation_fees(tx, get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); } @@ -4422,7 +4422,7 @@ vector< signed_transaction > wallet_api_impl::import_balance( string name_or_id, tx.operations.reserve( ctx.ops.size() ); for( const balance_claim_operation& op : ctx.ops ) tx.operations.emplace_back( op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees() ); tx.validate(); signed_transaction signed_tx = sign_transaction( tx, false ); for( const address& addr : ctx.addrs ) @@ -4616,12 +4616,12 @@ blind_confirmation wallet_api::transfer_from_blind( string from_blind_account_ke transfer_from_blind_operation from_blind; - auto fees = my->_remote_db->get_global_properties().parameters.current_fees; + auto fees = my->_remote_db->get_global_properties().parameters.get_current_fees(); fc::optional asset_obj = get_asset(symbol); FC_ASSERT(asset_obj.valid(), "Could not find asset matching ${asset}", ("asset", symbol)); auto amount = asset_obj->amount_from_string(amount_in); - from_blind.fee = fees->calculate_fee( from_blind, asset_obj->options.core_exchange_rate ); + from_blind.fee = fees.calculate_fee( from_blind, asset_obj->options.core_exchange_rate ); auto blind_in = asset_obj->amount_to_string( from_blind.fee + amount ); @@ -4636,7 +4636,7 @@ blind_confirmation wallet_api::transfer_from_blind( string from_blind_account_ke from_blind.amount = amount; from_blind.blinding_factor = conf.outputs.back().decrypted_memo.blinding_factor; from_blind.inputs.push_back( {conf.outputs.back().decrypted_memo.commitment, authority() } ); - from_blind.fee = fees->calculate_fee( from_blind, asset_obj->options.core_exchange_rate ); + from_blind.fee = fees.calculate_fee( from_blind, asset_obj->options.core_exchange_rate ); idump( (from_blind) ); conf.trx.operations.push_back(from_blind); @@ -4694,7 +4694,7 @@ blind_confirmation wallet_api::blind_transfer_help( string from_key_or_label, blind_transfer_operation blind_tr; blind_tr.outputs.resize(2); - auto fees = my->_remote_db->get_global_properties().parameters.current_fees; + auto fees = my->_remote_db->get_global_properties().parameters.get_current_fees(); auto amount = asset_obj->amount_from_string(amount_in); @@ -4704,7 +4704,7 @@ blind_confirmation wallet_api::blind_transfer_help( string from_key_or_label, //auto from_priv_key = my->get_private_key( from_key ); - blind_tr.fee = fees->calculate_fee( blind_tr, asset_obj->options.core_exchange_rate ); + blind_tr.fee = fees.calculate_fee( blind_tr, asset_obj->options.core_exchange_rate ); vector used; @@ -4918,7 +4918,7 @@ blind_confirmation wallet_api::transfer_to_blind( string from_account_id_or_name [&]( const blind_output& a, const blind_output& b ){ return a.commitment < b.commitment; } ); confirm.trx.operations.push_back( bop ); - my->set_operation_fees( confirm.trx, my->_remote_db->get_global_properties().parameters.current_fees); + my->set_operation_fees( confirm.trx, my->_remote_db->get_global_properties().parameters.get_current_fees()); confirm.trx.validate(); confirm.trx = sign_transaction(confirm.trx, broadcast); diff --git a/tests/common/database_fixture.cpp b/tests/common/database_fixture.cpp index 0c35fb7d8b..d6c7fe92fd 100644 --- a/tests/common/database_fixture.cpp +++ b/tests/common/database_fixture.cpp @@ -101,7 +101,7 @@ database_fixture::database_fixture(const fc::time_point_sec &initial_timestamp) genesis_state.initial_committee_candidates.push_back({name}); genesis_state.initial_witness_candidates.push_back({name, init_account_priv_key.get_public_key()}); } - genesis_state.initial_parameters.current_fees->zero_all_fees(); + genesis_state.initial_parameters.get_current_fees().zero_all_fees(); genesis_state_type::initial_asset_type init_mpa1; init_mpa1.symbol = "INITMPA"; @@ -642,7 +642,7 @@ void database_fixture::change_fees( ) { const chain_parameters& current_chain_params = db.get_global_properties().parameters; - const fee_schedule& current_fees = *(current_chain_params.current_fees); + const fee_schedule& current_fees = current_chain_params.get_current_fees(); flat_map< int, fee_parameters > fee_map; fee_map.reserve( current_fees.parameters.size() ); @@ -659,7 +659,7 @@ void database_fixture::change_fees( new_fees.scale = new_scale; chain_parameters new_chain_params = current_chain_params; - new_chain_params.current_fees = std::make_shared(new_fees); + new_chain_params.get_current_fees() = new_fees; db.modify(db.get_global_properties(), [&](global_property_object& p) { p.parameters = new_chain_params; @@ -1061,7 +1061,7 @@ void database_fixture::enable_fees() { db.modify(global_property_id_type()(db), [](global_property_object& gpo) { - gpo.parameters.current_fees = std::make_shared(fee_schedule::get_default()); + gpo.parameters.get_current_fees() = fee_schedule::get_default(); }); } @@ -1077,7 +1077,7 @@ void database_fixture::upgrade_to_lifetime_member( const account_object& account account_upgrade_operation op; op.account_to_upgrade = account.get_id(); op.upgrade_to_lifetime_member = true; - op.fee = db.get_global_properties().parameters.current_fees->calculate_fee(op); + op.fee = db.get_global_properties().parameters.get_current_fees().calculate_fee(op); trx.operations = {op}; PUSH_TX(db, trx, ~0); FC_ASSERT( op.account_to_upgrade(db).is_lifetime_member() ); @@ -1097,7 +1097,7 @@ void database_fixture::upgrade_to_annual_member(const account_object& account) try { account_upgrade_operation op; op.account_to_upgrade = account.get_id(); - op.fee = db.get_global_properties().parameters.current_fees->calculate_fee(op); + op.fee = db.get_global_properties().parameters.get_current_fees().calculate_fee(op); trx.operations = {op}; PUSH_TX(db, trx, ~0); FC_ASSERT( op.account_to_upgrade(db).is_member(db.head_block_time()) ); diff --git a/tests/tests/block_tests.cpp b/tests/tests/block_tests.cpp index 2c7eec7d05..80b57c4ae4 100644 --- a/tests/tests/block_tests.cpp +++ b/tests/tests/block_tests.cpp @@ -62,7 +62,7 @@ genesis_state_type make_genesis() { genesis_state.initial_committee_candidates.push_back({name}); genesis_state.initial_witness_candidates.push_back({name, init_account_priv_key.get_public_key()}); } - genesis_state.initial_parameters.current_fees->zero_all_fees(); + genesis_state.initial_parameters.get_current_fees().zero_all_fees(); return genesis_state; } diff --git a/tests/tests/fee_tests.cpp b/tests/tests/fee_tests.cpp index 5d4d12ca05..57d6febe3d 100644 --- a/tests/tests/fee_tests.cpp +++ b/tests/tests/fee_tests.cpp @@ -268,7 +268,7 @@ BOOST_AUTO_TEST_CASE(asset_claim_pool_test) claim_op.asset_id = asset_to_claim; claim_op.amount_to_claim = amount_to_fund; - const auto& curfees = *db.get_global_properties().parameters.current_fees; + const auto& curfees = db.get_global_properties().parameters.get_current_fees(); const auto& proposal_create_fees = curfees.get(); proposal_create_operation prop; prop.fee_paying_account = alice_id; @@ -462,7 +462,7 @@ BOOST_AUTO_TEST_CASE( cashback_test ) upgrade_to_lifetime_member(rog_id); BOOST_TEST_MESSAGE("Enable fees"); - const auto& fees = *db.get_global_properties().parameters.current_fees; + const auto& fees = db.get_global_properties().parameters.get_current_fees(); #define CustomRegisterActor(actor_name, registrar_name, referrer_name, referrer_rate) \ { \ @@ -709,29 +709,29 @@ BOOST_AUTO_TEST_CASE( account_create_fee_scaling ) auto accounts_per_scale = db.get_global_properties().parameters.accounts_per_fee_scale; db.modify(global_property_id_type()(db), [](global_property_object& gpo) { - gpo.parameters.current_fees = std::make_shared(fee_schedule::get_default()); - gpo.parameters.current_fees->get().basic_fee = 1; + gpo.parameters.get_current_fees() = fee_schedule::get_default(); + gpo.parameters.get_current_fees().get().basic_fee = 1; }); for( int i = db.get_dynamic_global_properties().accounts_registered_this_interval; i < accounts_per_scale; ++i ) { - BOOST_CHECK_EQUAL(db.get_global_properties().parameters.current_fees->get().basic_fee, 1u); + BOOST_CHECK_EQUAL(db.get_global_properties().parameters.get_current_fees().get().basic_fee, 1u); create_account("shill" + fc::to_string(i)); } for( int i = 0; i < accounts_per_scale; ++i ) { - BOOST_CHECK_EQUAL(db.get_global_properties().parameters.current_fees->get().basic_fee, 16u); + BOOST_CHECK_EQUAL(db.get_global_properties().parameters.get_current_fees().get().basic_fee, 16u); create_account("moreshills" + fc::to_string(i)); } for( int i = 0; i < accounts_per_scale; ++i ) { - BOOST_CHECK_EQUAL(db.get_global_properties().parameters.current_fees->get().basic_fee, 256u); + BOOST_CHECK_EQUAL(db.get_global_properties().parameters.get_current_fees().get().basic_fee, 256u); create_account("moarshills" + fc::to_string(i)); } - BOOST_CHECK_EQUAL(db.get_global_properties().parameters.current_fees->get().basic_fee, 4096u); + BOOST_CHECK_EQUAL(db.get_global_properties().parameters.get_current_fees().get().basic_fee, 4096u); generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); - BOOST_CHECK_EQUAL(db.get_global_properties().parameters.current_fees->get().basic_fee, 1u); + BOOST_CHECK_EQUAL(db.get_global_properties().parameters.get_current_fees().get().basic_fee, 1u); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( fee_refund_test ) @@ -3694,7 +3694,7 @@ BOOST_AUTO_TEST_CASE( issue_429_test ) // make sure the database requires our fee to be nonzero enable_fees(); - const auto& fees = *db.get_global_properties().parameters.current_fees; + const auto& fees = db.get_global_properties().parameters.get_current_fees(); auto fees_to_pay = fees.get(); { @@ -3767,7 +3767,7 @@ BOOST_AUTO_TEST_CASE( issue_433_test ) // make sure the database requires our fee to be nonzero enable_fees(); - const auto& fees = *db.get_global_properties().parameters.current_fees; + const auto& fees = db.get_global_properties().parameters.get_current_fees(); const auto asset_create_fees = fees.get(); fund_fee_pool( alice, myusd, 5*asset_create_fees.long_symbol ); @@ -3808,7 +3808,7 @@ BOOST_AUTO_TEST_CASE( issue_433_indirect_test ) // make sure the database requires our fee to be nonzero enable_fees(); - const auto& fees = *db.get_global_properties().parameters.current_fees; + const auto& fees = db.get_global_properties().parameters.get_current_fees(); const auto asset_create_fees = fees.get(); fund_fee_pool( alice, myusd, 5*asset_create_fees.long_symbol ); diff --git a/tests/tests/operation_tests.cpp b/tests/tests/operation_tests.cpp index 76fc1c78f1..30734f2d43 100644 --- a/tests/tests/operation_tests.cpp +++ b/tests/tests/operation_tests.cpp @@ -643,7 +643,7 @@ BOOST_AUTO_TEST_CASE( call_order_update_target_cr_hardfork_time_test ) op.delta_debt = delta_debt; op.extensions.value.target_collateral_ratio = target_cr; - const auto& curfees = *db.get_global_properties().parameters.current_fees; + const auto& curfees = db.get_global_properties().parameters.get_current_fees(); const auto& proposal_create_fees = curfees.get(); proposal_create_operation prop; prop.fee_paying_account = proposer.id; @@ -968,7 +968,7 @@ BOOST_AUTO_TEST_CASE( update_account ) account_upgrade_operation op; op.account_to_upgrade = nathan.id; op.upgrade_to_lifetime_member = true; - op.fee = db.get_global_properties().parameters.current_fees->calculate_fee(op); + op.fee = db.get_global_properties().parameters.get_current_fees().calculate_fee(op); trx.operations = {op}; PUSH_TX( db, trx, ~0 ); } @@ -1316,7 +1316,7 @@ BOOST_AUTO_TEST_CASE( update_uia_issuer ) op.new_issuer = new_issuer.id; op.asset_to_update = asset_id; - const auto& curfees = *db.get_global_properties().parameters.current_fees; + const auto& curfees = db.get_global_properties().parameters.get_current_fees(); const auto& proposal_create_fees = curfees.get(); proposal_create_operation prop; prop.fee_paying_account = issuer.id; diff --git a/tests/tests/uia_tests.cpp b/tests/tests/uia_tests.cpp index 0efc4c5ef9..d51a49f955 100644 --- a/tests/tests/uia_tests.cpp +++ b/tests/tests/uia_tests.cpp @@ -543,7 +543,7 @@ BOOST_AUTO_TEST_CASE( asset_name_test ) op_p.common_options.core_exchange_rate = asset( 1 ) / asset( 1, asset_id_type( 1 ) ); op_p.fee = core.amount(0); - const auto& curfees = *db.get_global_properties().parameters.current_fees; + const auto& curfees = db.get_global_properties().parameters.get_current_fees(); const auto& proposal_create_fees = curfees.get(); proposal_create_operation prop; prop.fee_paying_account = alice_id; From b7a2a7bdf007e6fbffd947cd77f3f1b1e01769ec Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Sun, 24 Mar 2019 19:27:03 -0500 Subject: [PATCH 2/5] Ref #1670: Rename non-const getter for clarity Rename non-const `get_current_fees()` to `get_mutable_fees()` to make its non-constness explicit at the call site --- libraries/app/application.cpp | 2 +- libraries/chain/account_evaluator.cpp | 2 +- libraries/chain/db_init.cpp | 4 ++-- libraries/chain/db_maint.cpp | 2 +- .../include/graphene/chain/protocol/chain_parameters.hpp | 2 +- libraries/wallet/wallet.cpp | 2 +- tests/common/database_fixture.cpp | 6 +++--- tests/tests/block_tests.cpp | 2 +- tests/tests/fee_tests.cpp | 4 ++-- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index b0b446e350..4217b2e934 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -81,7 +81,7 @@ namespace detail { auto nathan_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("nathan"))); dlog("Allocating all stake to ${key}", ("key", utilities::key_to_wif(nathan_key))); graphene::chain::genesis_state_type initial_state; - initial_state.initial_parameters.get_current_fees() = fee_schedule::get_default(); + initial_state.initial_parameters.get_mutable_fees() = fee_schedule::get_default(); initial_state.initial_active_witnesses = GRAPHENE_DEFAULT_MIN_WITNESS_COUNT; initial_state.initial_timestamp = time_point_sec(time_point::now().sec_since_epoch() / initial_state.initial_parameters.block_interval * diff --git a/libraries/chain/account_evaluator.cpp b/libraries/chain/account_evaluator.cpp index da55e54ff6..4797f497da 100644 --- a/libraries/chain/account_evaluator.cpp +++ b/libraries/chain/account_evaluator.cpp @@ -240,7 +240,7 @@ object_id_type account_create_evaluator::do_apply( const account_create_operatio && global_properties.parameters.account_fee_scale_bitshifts != 0 ) { d.modify(global_properties, [](global_property_object& p) { - p.parameters.get_current_fees().get().basic_fee <<= p.parameters.account_fee_scale_bitshifts; + p.parameters.get_mutable_fees().get().basic_fee <<= p.parameters.account_fee_scale_bitshifts; }); } diff --git a/libraries/chain/db_init.cpp b/libraries/chain/db_init.cpp index d8def12e50..1029947e0c 100644 --- a/libraries/chain/db_init.cpp +++ b/libraries/chain/db_init.cpp @@ -422,7 +422,7 @@ void database::init_genesis(const genesis_state_type& genesis_state) p.parameters = genesis_state.initial_parameters; // Set fees to zero initially, so that genesis initialization needs not pay them // We'll fix it at the end of the function - p.parameters.get_current_fees().zero_all_fees(); + p.parameters.get_mutable_fees().zero_all_fees(); }); _p_dyn_global_prop_obj = & create([&genesis_state](dynamic_global_property_object& p) { @@ -692,7 +692,7 @@ void database::init_genesis(const genesis_state_type& genesis_state) // Enable fees modify(get_global_properties(), [&genesis_state](global_property_object& p) { - p.parameters.get_current_fees() = genesis_state.initial_parameters.get_current_fees(); + p.parameters.get_mutable_fees() = genesis_state.initial_parameters.get_current_fees(); }); // Create witness scheduler diff --git a/libraries/chain/db_maint.cpp b/libraries/chain/db_maint.cpp index ba045a1b10..26498826d4 100644 --- a/libraries/chain/db_maint.cpp +++ b/libraries/chain/db_maint.cpp @@ -1236,7 +1236,7 @@ void database::perform_chain_maintenance(const signed_block& next_block, const g modify(gpo, [&dgpo](global_property_object& p) { // Remove scaling of account registration fee - p.parameters.get_current_fees().get().basic_fee >>= p.parameters.account_fee_scale_bitshifts * + p.parameters.get_mutable_fees().get().basic_fee >>= p.parameters.account_fee_scale_bitshifts * (dgpo.accounts_registered_this_interval / p.parameters.accounts_per_fee_scale); if( p.pending_parameters ) diff --git a/libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp b/libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp index d9e5affea6..f0eb522fe5 100644 --- a/libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp +++ b/libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp @@ -39,7 +39,7 @@ namespace graphene { namespace chain { /** using a shared_ptr breaks the circular dependency created between operations and the fee schedule */ std::shared_ptr current_fees; ///< current schedule of fees const fee_schedule& get_current_fees() const { FC_ASSERT(current_fees); return *current_fees; } - fee_schedule& get_current_fees() { FC_ASSERT(current_fees); return const_cast(*current_fees); } + fee_schedule& get_mutable_fees() { FC_ASSERT(current_fees); return const_cast(*current_fees); } uint8_t block_interval = GRAPHENE_DEFAULT_BLOCK_INTERVAL; ///< interval in seconds between blocks uint32_t maintenance_interval = GRAPHENE_DEFAULT_MAINTENANCE_INTERVAL; ///< interval in sections between blockchain maintenance events diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index f994cb4a0d..02552b5f6b 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -2751,7 +2751,7 @@ class wallet_api_impl new_fees.scale = scale; chain_parameters new_params = current_params; - new_params.get_current_fees() = new_fees; + new_params.get_mutable_fees() = new_fees; committee_member_update_global_parameters_operation update_op; update_op.new_parameters = new_params; diff --git a/tests/common/database_fixture.cpp b/tests/common/database_fixture.cpp index d6c7fe92fd..af0e9513e5 100644 --- a/tests/common/database_fixture.cpp +++ b/tests/common/database_fixture.cpp @@ -101,7 +101,7 @@ database_fixture::database_fixture(const fc::time_point_sec &initial_timestamp) genesis_state.initial_committee_candidates.push_back({name}); genesis_state.initial_witness_candidates.push_back({name, init_account_priv_key.get_public_key()}); } - genesis_state.initial_parameters.get_current_fees().zero_all_fees(); + genesis_state.initial_parameters.get_mutable_fees().zero_all_fees(); genesis_state_type::initial_asset_type init_mpa1; init_mpa1.symbol = "INITMPA"; @@ -659,7 +659,7 @@ void database_fixture::change_fees( new_fees.scale = new_scale; chain_parameters new_chain_params = current_chain_params; - new_chain_params.get_current_fees() = new_fees; + new_chain_params.get_mutable_fees() = new_fees; db.modify(db.get_global_properties(), [&](global_property_object& p) { p.parameters = new_chain_params; @@ -1061,7 +1061,7 @@ void database_fixture::enable_fees() { db.modify(global_property_id_type()(db), [](global_property_object& gpo) { - gpo.parameters.get_current_fees() = fee_schedule::get_default(); + gpo.parameters.get_mutable_fees() = fee_schedule::get_default(); }); } diff --git a/tests/tests/block_tests.cpp b/tests/tests/block_tests.cpp index 80b57c4ae4..9b336eb2d5 100644 --- a/tests/tests/block_tests.cpp +++ b/tests/tests/block_tests.cpp @@ -62,7 +62,7 @@ genesis_state_type make_genesis() { genesis_state.initial_committee_candidates.push_back({name}); genesis_state.initial_witness_candidates.push_back({name, init_account_priv_key.get_public_key()}); } - genesis_state.initial_parameters.get_current_fees().zero_all_fees(); + genesis_state.initial_parameters.get_mutable_fees().zero_all_fees(); return genesis_state; } diff --git a/tests/tests/fee_tests.cpp b/tests/tests/fee_tests.cpp index 57d6febe3d..0ae36c1523 100644 --- a/tests/tests/fee_tests.cpp +++ b/tests/tests/fee_tests.cpp @@ -709,8 +709,8 @@ BOOST_AUTO_TEST_CASE( account_create_fee_scaling ) auto accounts_per_scale = db.get_global_properties().parameters.accounts_per_fee_scale; db.modify(global_property_id_type()(db), [](global_property_object& gpo) { - gpo.parameters.get_current_fees() = fee_schedule::get_default(); - gpo.parameters.get_current_fees().get().basic_fee = 1; + gpo.parameters.get_mutable_fees() = fee_schedule::get_default(); + gpo.parameters.get_mutable_fees().get().basic_fee = 1; }); for( int i = db.get_dynamic_global_properties().accounts_registered_this_interval; i < accounts_per_scale; ++i ) From 51875b02523c73353850eea2b935acde17811304 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Mon, 25 Mar 2019 09:34:09 -0500 Subject: [PATCH 3/5] Update fc submodule --- libraries/fc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/fc b/libraries/fc index a0ca5ab29d..4d4ec62f5d 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit a0ca5ab29d259cc027920fd342a86e943157574a +Subproject commit 4d4ec62f5d6aefee101beaec71ab4c940eb85bb6 From 94e3aac3f86e51bbbf7128cfe1ca486d0ded52d2 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Sat, 6 Apr 2019 23:39:07 -0500 Subject: [PATCH 4/5] Minor style change --- libraries/egenesis/embed_genesis.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/egenesis/embed_genesis.cpp b/libraries/egenesis/embed_genesis.cpp index d88d43b6ec..25af734566 100644 --- a/libraries/egenesis/embed_genesis.cpp +++ b/libraries/egenesis/embed_genesis.cpp @@ -285,4 +285,4 @@ int main( int argc, char** argv ) } return main_return; -} catch( fc::exception& e ) { edump((e)); throw; } } +} FC_LOG_AND_RETHROW() } From 159a0cc7f0119ccb798627c9c4eca14dfc51e374 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Tue, 9 Apr 2019 17:39:17 -0500 Subject: [PATCH 5/5] Ref #1670: Fix build against latest develop --- libraries/wallet/wallet.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 02552b5f6b..c19cbcf65b 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -1890,7 +1890,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(create_op); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); @@ -1915,7 +1915,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(update_op); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); @@ -1939,7 +1939,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(update_op); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast);