Skip to content

Commit

Permalink
Merge pull request #1352 from cogutvalera/issue_1269
Browse files Browse the repository at this point in the history
Change call_order_update_operation to return order_id #1269
  • Loading branch information
pmconrad authored Oct 1, 2018
2 parents 1d2c5f8 + 73e9b9d commit 293e8da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ namespace graphene { namespace chain {
typedef call_order_update_operation operation_type;

void_result do_evaluate( const call_order_update_operation& o );
void_result do_apply( const call_order_update_operation& o );
object_id_type do_apply( const call_order_update_operation& o );

bool _closing_order = false;
const asset_object* _debt_asset = nullptr;
Expand Down
11 changes: 6 additions & 5 deletions libraries/chain/market_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ void_result call_order_update_evaluator::do_evaluate(const call_order_update_ope
} FC_CAPTURE_AND_RETHROW( (o) ) }


void_result call_order_update_evaluator::do_apply(const call_order_update_operation& o)
object_id_type call_order_update_evaluator::do_apply(const call_order_update_operation& o)
{ try {
database& d = db();

Expand Down Expand Up @@ -220,6 +220,7 @@ void_result call_order_update_evaluator::do_apply(const call_order_update_operat
auto& call_idx = d.get_index_type<call_order_index>().indices().get<by_account>();
auto itr = call_idx.find( boost::make_tuple(o.funding_account, o.delta_debt.asset_id) );
const call_order_object* call_obj = nullptr;
call_order_id_type call_order_id;

optional<price> old_collateralization;
optional<share_type> old_debt;
Expand All @@ -237,18 +238,20 @@ void_result call_order_update_evaluator::do_apply(const call_order_update_operat
_bitasset_data->current_feed.maintenance_collateral_ratio);
call.target_collateral_ratio = o.extensions.value.target_collateral_ratio;
});
call_order_id = call_obj->id;
}
else // updating existing debt position
{
call_obj = &*itr;
auto new_collateral = call_obj->collateral + o.delta_collateral.amount;
auto new_debt = call_obj->debt + o.delta_debt.amount;
call_order_id = call_obj->id;

if( new_debt == 0 )
{
FC_ASSERT( new_collateral == 0, "Should claim all collateral when closing debt position" );
d.remove( *call_obj );
return void_result();
return call_order_id;
}

FC_ASSERT( new_collateral > 0 && new_debt > 0,
Expand All @@ -269,8 +272,6 @@ void_result call_order_update_evaluator::do_apply(const call_order_update_operat
// then we must check for margin calls and other issues
if( !_bitasset_data->is_prediction_market )
{
call_order_id_type call_order_id = call_obj->id;

// check to see if the order needs to be margin called now, but don't allow black swans and require there to be
// limit orders available that could be used to fill the order.
// Note: due to https://github.com/bitshares/bitshares-core/issues/649, before core-343 hard fork,
Expand Down Expand Up @@ -331,7 +332,7 @@ void_result call_order_update_evaluator::do_apply(const call_order_update_operat
}
}

return void_result();
return call_order_id;
} FC_CAPTURE_AND_RETHROW( (o) ) }

void_result bid_collateral_evaluator::do_evaluate(const bid_collateral_operation& o)
Expand Down

0 comments on commit 293e8da

Please sign in to comment.