From 4bbaad02a78e6b9b50a0267bb590d1718b71752f Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Wed, 1 Jul 2015 14:05:42 -0400 Subject: [PATCH] Progress on Burn, Reserve, Issue, Retire #108 --- libraries/chain/db_maint.cpp | 6 +++--- libraries/chain/include/graphene/chain/asset_object.hpp | 5 ++++- tests/tests/operation_tests.cpp | 6 +++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/libraries/chain/db_maint.cpp b/libraries/chain/db_maint.cpp index c33ad3d0..9c79dfdf 100644 --- a/libraries/chain/db_maint.cpp +++ b/libraries/chain/db_maint.cpp @@ -233,13 +233,13 @@ share_type database::get_max_budget( fc::time_point_sec now )const int64_t dt = (now - dpo.last_budget_time).to_seconds(); - // We'll consider accumulated_fees to be burned at the BEGINNING + // We'll consider accumulated_fees to be reserved at the BEGINNING // of the maintenance interval. However, for speed we only // call modify() on the asset_dynamic_data_object once at the // end of the maintenance interval. Thus the accumulated_fees // are available for the budget at this point, but not included - // in core.burned(). - share_type reserve = core.burned(*this) + core_dd.accumulated_fees; + // in core.reserved(). + share_type reserve = core.reserved(*this) + core_dd.accumulated_fees; // Similarly, we consider leftover witness_budget to be burned // at the BEGINNING of the maintenance interval. reserve += dpo.witness_budget; diff --git a/libraries/chain/include/graphene/chain/asset_object.hpp b/libraries/chain/include/graphene/chain/asset_object.hpp index a1435d47..365edf07 100644 --- a/libraries/chain/include/graphene/chain/asset_object.hpp +++ b/libraries/chain/include/graphene/chain/asset_object.hpp @@ -220,8 +220,11 @@ namespace graphene { namespace chain { const asset_dynamic_data_object& dynamic_data(const DB& db)const { return db.get(dynamic_asset_data_id); } + /** + * The total amount of an asset that is reserved for future issuance. + */ template - share_type burned( const DB& db )const + share_type reserved( const DB& db )const { return options.max_supply - dynamic_data(db).current_supply; } }; diff --git a/tests/tests/operation_tests.cpp b/tests/tests/operation_tests.cpp index 3dca7e1d..f64bf6a8 100644 --- a/tests/tests/operation_tests.cpp +++ b/tests/tests/operation_tests.cpp @@ -1188,9 +1188,9 @@ BOOST_AUTO_TEST_CASE( witness_withdraw_pay_test ) schedule_maint(); // The 80% lifetime referral fee went to the committee account, which burned it. Check that it's here. - BOOST_CHECK_EQUAL( core->burned(db).value, 840000000 ); + BOOST_CHECK_EQUAL( core->reserved(db).value, 840000000 ); generate_block(); - BOOST_CHECK_EQUAL( core->burned(db).value, 840000000 + 210000000 - ref_budget ); + BOOST_CHECK_EQUAL( core->reserved(db).value, 840000000 + 210000000 - ref_budget ); BOOST_CHECK_EQUAL( db.get_dynamic_global_properties().witness_budget.value, ref_budget ); witness = &db.fetch_block_by_number(db.head_block_num())->witness(db); // first witness paid from old budget (so no pay) @@ -1235,7 +1235,7 @@ BOOST_AUTO_TEST_CASE( witness_withdraw_pay_test ) trx.clear(); BOOST_CHECK_EQUAL(get_balance(witness->witness_account(db), *core), witness_ppb - 1/*fee*/); - BOOST_CHECK_EQUAL(core->burned(db).value, 840000000 + 210000000 - ref_budget ); + BOOST_CHECK_EQUAL(core->reserved(db).value, 840000000 + 210000000 - ref_budget ); BOOST_CHECK_EQUAL(witness->accumulated_income.value, 0); } FC_LOG_AND_RETHROW() }