Skip to content

Commit

Permalink
Save a ptr to asset_dynamic_data_object
Browse files Browse the repository at this point in the history
  • Loading branch information
jmjatlanta committed Jan 18, 2019
1 parent 6c5e48f commit 097799b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 0 additions & 1 deletion libraries/chain/db_maint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,6 @@ void database::process_bitassets()
*/
void process_hf_1465( database& db )
{
const auto head_time = db.head_block_time();
const auto head_num = db.head_block_num();
wlog( "Processing hard fork core-1465 at block ${n}", ("n",head_num) );
// for each market issued asset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ namespace graphene { namespace chain {
const account_object* _paying_account = nullptr;
const call_order_object* _order = nullptr;
const asset_bitasset_data_object* _bitasset_data = nullptr;
const asset_dynamic_data_object* _dynamic_data_obj = nullptr;
};

class bid_collateral_evaluator : public evaluator<bid_collateral_evaluator>
Expand Down
7 changes: 5 additions & 2 deletions libraries/chain/market_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ void_result call_order_update_evaluator::do_evaluate(const call_order_update_ope
else if( _bitasset_data->current_feed.settlement_price.is_null() )
FC_THROW_EXCEPTION(insufficient_feeds, "Cannot borrow asset with no price feed.");

_dynamic_data_obj = &_debt_asset->dynamic_asset_data_id(d);
FC_ASSERT( _dynamic_data_obj->current_supply + o.delta_debt.amount >= 0,
"This transaction would bring current supply below zero.");

// Note: there was code here checking whether the account has enough balance to increase delta collateral,
// which is now removed since the check is implicitly done later by `adjust_balance()` in `do_apply()`.

Expand All @@ -204,9 +208,8 @@ object_id_type call_order_update_evaluator::do_apply(const call_order_update_ope
d.adjust_balance( o.funding_account, o.delta_debt );

// Deduct the debt paid from the total supply of the debt asset.
d.modify(_debt_asset->dynamic_asset_data_id(d), [&](asset_dynamic_data_object& dynamic_asset) {
d.modify(*_dynamic_data_obj, [&](asset_dynamic_data_object& dynamic_asset) {
dynamic_asset.current_supply += o.delta_debt.amount;
FC_ASSERT(dynamic_asset.current_supply >= 0);
});
}

Expand Down

0 comments on commit 097799b

Please sign in to comment.