Progress on Burn, Reserve, Issue, Retire #108

This commit is contained in:
Daniel Larimer 2015-07-01 14:05:42 -04:00
parent e336691e59
commit 4bbaad02a7
3 changed files with 10 additions and 7 deletions

View file

@ -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;

View file

@ -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<class DB>
share_type burned( const DB& db )const
share_type reserved( const DB& db )const
{ return options.max_supply - dynamic_data(db).current_supply; }
};

View file

@ -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() }