Skip to content

Commit

Permalink
Merge pull request #2977 from steemit/2961-rc-immediate-delegation
Browse files Browse the repository at this point in the history
Increment rc_account.manabar immediately for positive RC changes #2961
  • Loading branch information
Michael Vandeberg authored Sep 28, 2018
2 parents a0dd821 + ae9508c commit 042dc59
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions libraries/plugins/rc/rc_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -888,15 +888,20 @@ void rc_plugin_impl::on_pre_apply_operation( const operation_notification& note
note.op.visit( vtor );
}

void update_last_vesting( database& db, const std::vector< account_name_type >& regen_accounts )
void update_modified_accounts( database& db, const std::vector< account_name_type >& regen_accounts )
{
for( const account_name_type& name : regen_accounts )
{
const account_object& account = db.get< account_object, by_name >( name );
const rc_account_object& rc_account = db.get< rc_account_object, by_name >( name );

int64_t new_last_max_rc = get_maximum_rc( account, rc_account );
int64_t drc = new_last_max_rc - rc_account.last_max_rc;

db.modify( rc_account, [&]( rc_account_object& rca )
{
rca.last_max_rc = get_maximum_rc( account, rca );
rca.last_max_rc = new_last_max_rc;
rca.rc_manabar.current_mana += std::max( drc, int64_t( 0 ) );
} );
}
}
Expand All @@ -915,7 +920,7 @@ void rc_plugin_impl::on_post_apply_operation( const operation_notification& note
post_apply_operation_visitor vtor( modified_accounts, _db, now, gpo.head_block_number, gpo.current_witness );
note.op.visit( vtor );

update_last_vesting( _db, modified_accounts );
update_modified_accounts( _db, modified_accounts );
}

void rc_plugin_impl::validate_database()
Expand Down

0 comments on commit 042dc59

Please sign in to comment.