Skip to content

Commit

Permalink
Merge pull request #1168 from oxarbitrage/issue1164
Browse files Browse the repository at this point in the history
use get_account_from_string in get_account_limit_orders
  • Loading branch information
abitmore authored Jul 22, 2018
2 parents 761f652 + b55072f commit 31554c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
19 changes: 5 additions & 14 deletions libraries/app/database_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>

// Markets / feeds
vector<limit_order_object> get_limit_orders(asset_id_type a, asset_id_type b, uint32_t limit)const;
vector<limit_order_object> get_account_limit_orders( const string& name_or_id,
vector<limit_order_object> get_account_limit_orders( const string& account_name_or_id,
const string &base,
const string &quote, uint32_t limit,
optional<limit_order_id_type> ostart_id,
Expand Down Expand Up @@ -663,30 +663,21 @@ vector<optional<account_object>> database_api_impl::get_accounts(const vector<st
return result;
}

vector<limit_order_object> database_api::get_account_limit_orders( const string& name_or_id, const string &base,
vector<limit_order_object> database_api::get_account_limit_orders( const string& account_name_or_id, const string &base,
const string &quote, uint32_t limit, optional<limit_order_id_type> ostart_id, optional<price> ostart_price)
{
return my->get_account_limit_orders( name_or_id, base, quote, limit, ostart_id, ostart_price );
return my->get_account_limit_orders( account_name_or_id, base, quote, limit, ostart_id, ostart_price );
}

vector<limit_order_object> database_api_impl::get_account_limit_orders( const string& name_or_id, const string &base,
vector<limit_order_object> database_api_impl::get_account_limit_orders( const string& account_name_or_id, const string &base,
const string &quote, uint32_t limit, optional<limit_order_id_type> ostart_id, optional<price> ostart_price)
{
FC_ASSERT( limit <= 101 );

vector<limit_order_object> results;
const account_object* account = nullptr;
uint32_t count = 0;

if (std::isdigit(name_or_id[0]))
account = _db.find(fc::variant(name_or_id, 1).as<account_id_type>(1));
else
{
const auto& idx = _db.get_index_type<account_index>().indices().get<by_name>();
auto itr = idx.find(name_or_id);
if (itr != idx.end())
account = &*itr;
}
const account_object* account = get_account_from_string(account_name_or_id);
if (account == nullptr)
return results;

Expand Down
8 changes: 4 additions & 4 deletions libraries/app/include/graphene/app/database_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,25 +280,25 @@ class database_api
* @brief Fetch all orders relevant to the specified account and specified market, result orders
* are sorted descendingly by price
*
* @param name_or_id The name or ID of an account to retrieve
* @param account_name_or_id The name or ID of an account to retrieve
* @param base Base asset
* @param quote Quote asset
* @param limit The limitation of items each query can fetch, not greater than 101
* @param start_id Start order id, fetch orders which price lower than this order, or price equal to this order
* but order ID greater than this order
* @param start_price Fetch orders with price lower than or equal to this price
*
* @return List of orders from @ref name_or_id to the corresponding account
* @return List of orders from @ref account_name_or_id to the corresponding account
*
* @note
* 1. if @ref name_or_id cannot be tied to an account, empty result will be returned
* 1. if @ref account_name_or_id cannot be tied to an account, empty result will be returned
* 2. @ref start_id and @ref start_price can be empty, if so the api will return the "first page" of orders;
* if start_id is specified, its price will be used to do page query preferentially, otherwise the start_price
* will be used; start_id and start_price may be used cooperatively in case of the order specified by start_id
* was just canceled accidentally, in such case, the result orders' price may lower or equal to start_price,
* but orders' id greater than start_id
*/
vector<limit_order_object> get_account_limit_orders( const string& name_or_id,
vector<limit_order_object> get_account_limit_orders( const string& account_name_or_id,
const string &base,
const string &quote,
uint32_t limit = 101,
Expand Down

0 comments on commit 31554c1

Please sign in to comment.