Deprecate annual memberships #613
This commit is contained in:
parent
da9ee0c499
commit
b7b4d4fc5d
3 changed files with 43 additions and 1 deletions
|
|
@ -371,11 +371,13 @@ void_result account_upgrade_evaluator::do_apply(const account_upgrade_evaluator:
|
|||
a.lifetime_referrer_fee_percentage = GRAPHENE_100_PERCENT - a.network_fee_percentage;
|
||||
} else if( a.is_annual_member(d.head_block_time()) ) {
|
||||
// Renew an annual subscription that's still in effect.
|
||||
FC_ASSERT( d.head_block_time() <= HARDFORK_613_TIME );
|
||||
FC_ASSERT(a.membership_expiration_date - d.head_block_time() < fc::days(3650),
|
||||
"May not extend annual membership more than a decade into the future.");
|
||||
a.membership_expiration_date += fc::days(365);
|
||||
} else {
|
||||
// Upgrade from basic account.
|
||||
FC_ASSERT( d.head_block_time() <= HARDFORK_613_TIME );
|
||||
a.statistics(d).process_fees(a, d);
|
||||
assert(a.is_basic_account(d.head_block_time()));
|
||||
a.referrer = a.get_id();
|
||||
|
|
|
|||
|
|
@ -684,6 +684,37 @@ void create_buyback_orders( database& db )
|
|||
return;
|
||||
}
|
||||
|
||||
void deprecate_annual_members( database& db )
|
||||
{
|
||||
const auto& account_idx = db.get_index_type<account_index>().indices().get<by_id>();
|
||||
fc::time_point_sec now = db.head_block_time();
|
||||
for( const account_object& acct : account_idx )
|
||||
{
|
||||
try
|
||||
{
|
||||
transaction_evaluation_state upgrade_context(&db);
|
||||
upgrade_context.skip_fee_schedule_check = true;
|
||||
|
||||
if( acct.is_annual_member( now ) )
|
||||
{
|
||||
account_upgrade_operation upgrade_vop;
|
||||
upgrade_vop.fee = asset( 0, asset_id_type() );
|
||||
upgrade_vop.account_to_upgrade = acct.id;
|
||||
upgrade_vop.upgrade_to_lifetime_member = true;
|
||||
db.apply_operation( upgrade_context, upgrade_vop );
|
||||
}
|
||||
}
|
||||
catch( const fc::exception& e )
|
||||
{
|
||||
// we can in fact get here, e.g. if asset issuer of buy/sell asset blacklists/whitelists the buyback account
|
||||
wlog( "Skipping annual member deprecate processing for account ${a} (${an}) at block ${n}; exception was ${e}",
|
||||
("a", acct.id)("an", acct.name)("n", db.head_block_num())("e", e.to_detail_string()) );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void database::perform_chain_maintenance(const signed_block& next_block, const global_property_object& global_props)
|
||||
{
|
||||
const auto& gpo = get_global_properties();
|
||||
|
|
@ -830,7 +861,12 @@ void database::perform_chain_maintenance(const signed_block& next_block, const g
|
|||
}
|
||||
}
|
||||
|
||||
modify(get_dynamic_global_properties(), [next_maintenance_time](dynamic_global_property_object& d) {
|
||||
const dynamic_global_property_object& dgpo = get_dynamic_global_properties();
|
||||
|
||||
if( (dgpo.next_maintenance_time < HARDFORK_613_TIME) && (next_maintenance_time >= HARDFORK_613_TIME) )
|
||||
deprecate_annual_members(*this);
|
||||
|
||||
modify(dgpo, [next_maintenance_time](dynamic_global_property_object& d) {
|
||||
d.next_maintenance_time = next_maintenance_time;
|
||||
d.accounts_registered_this_interval = 0;
|
||||
});
|
||||
|
|
|
|||
4
libraries/chain/hardfork.d/613.hf
Normal file
4
libraries/chain/hardfork.d/613.hf
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
// #613 Deprecate annual membership
|
||||
#ifndef HARDFORK_613_TIME
|
||||
#define HARDFORK_613_TIME (fc::time_point_sec( 1458061200 ))
|
||||
#endif
|
||||
Loading…
Reference in a new issue