From cca5fd8dc3770e2adde90943e9a2529259b9ffdc Mon Sep 17 00:00:00 2001 From: Alfredo Date: Sat, 21 Jul 2018 19:40:53 -0300 Subject: [PATCH] use get_account_from_string in get_account_limit_orders --- libraries/app/database_api.cpp | 19 +++++-------------- .../app/include/graphene/app/database_api.hpp | 2 +- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index a674250153..77407e1045 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -105,7 +105,7 @@ class database_api_impl : public std::enable_shared_from_this // Markets / feeds vector get_limit_orders(asset_id_type a, asset_id_type b, uint32_t limit)const; - vector get_account_limit_orders( const string& name_or_id, + vector get_account_limit_orders( const string& account_name_or_id, const string &base, const string "e, uint32_t limit, optional ostart_id, @@ -663,30 +663,21 @@ vector> database_api_impl::get_accounts(const vector database_api::get_account_limit_orders( const string& name_or_id, const string &base, +vector database_api::get_account_limit_orders( const string& account_name_or_id, const string &base, const string "e, uint32_t limit, optional ostart_id, optional 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 database_api_impl::get_account_limit_orders( const string& name_or_id, const string &base, +vector database_api_impl::get_account_limit_orders( const string& account_name_or_id, const string &base, const string "e, uint32_t limit, optional ostart_id, optional ostart_price) { FC_ASSERT( limit <= 101 ); vector 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(1)); - else - { - const auto& idx = _db.get_index_type().indices().get(); - 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; diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index 488b10c35a..c0da5697e1 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -298,7 +298,7 @@ class database_api * 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 get_account_limit_orders( const string& name_or_id, + vector get_account_limit_orders( const string& account_name_or_id, const string &base, const string "e, uint32_t limit = 101,