database_fixture: Make borrow() return object
This commit is contained in:
parent
11a5d2b620
commit
bc9a3173ec
2 changed files with 12 additions and 4 deletions
|
|
@ -755,7 +755,7 @@ void database_fixture::force_settle( const account_object& who, asset what )
|
|||
verify_asset_supplies(db);
|
||||
} FC_CAPTURE_AND_RETHROW( (who)(what) ) }
|
||||
|
||||
void database_fixture::borrow(const account_object& who, asset what, asset collateral)
|
||||
const call_order_object* database_fixture::borrow(const account_object& who, asset what, asset collateral)
|
||||
{ try {
|
||||
trx.set_expiration(db.head_block_time() + fc::minutes(1));
|
||||
trx.operations.clear();
|
||||
|
|
@ -769,6 +769,14 @@ void database_fixture::borrow(const account_object& who, asset what, asset coll
|
|||
db.push_transaction(trx, ~0);
|
||||
trx.operations.clear();
|
||||
verify_asset_supplies(db);
|
||||
|
||||
auto& call_idx = db.get_index_type<call_order_index>().indices().get<by_account>();
|
||||
auto itr = call_idx.find( boost::make_tuple(who.id, what.asset_id) );
|
||||
const call_order_object* call_obj = nullptr;
|
||||
|
||||
if( itr != call_idx.end() )
|
||||
call_obj = &*itr;
|
||||
return call_obj;
|
||||
} FC_CAPTURE_AND_RETHROW( (who.name)(what)(collateral) ) }
|
||||
|
||||
void database_fixture::cover(const account_object& who, asset what, asset collateral)
|
||||
|
|
|
|||
|
|
@ -198,9 +198,9 @@ struct database_fixture {
|
|||
void publish_feed(asset_id_type mia, account_id_type by, const price_feed& f)
|
||||
{ publish_feed(mia(db), by(db), f); }
|
||||
void publish_feed(const asset_object& mia, const account_object& by, const price_feed& f);
|
||||
void borrow(account_id_type who, asset what, asset collateral)
|
||||
{ borrow(who(db), what, collateral); }
|
||||
void borrow(const account_object& who, asset what, asset collateral);
|
||||
const call_order_object* borrow(account_id_type who, asset what, asset collateral)
|
||||
{ return borrow(who(db), what, collateral); }
|
||||
const call_order_object* borrow(const account_object& who, asset what, asset collateral);
|
||||
void cover(account_id_type who, asset what, asset collateral_freed)
|
||||
{ cover(who(db), what, collateral_freed); }
|
||||
void cover(const account_object& who, asset what, asset collateral_freed);
|
||||
|
|
|
|||
Loading…
Reference in a new issue