adding method to get account by name

This commit is contained in:
Daniel Larimer 2015-08-03 16:22:19 -04:00
parent 99d6450473
commit 39c05a0b2e
2 changed files with 12 additions and 0 deletions

View file

@ -1155,4 +1155,13 @@ namespace graphene { namespace app {
return result;
}
optional<account_object> database_api::get_account_by_name( string name )const
{
const auto& idx = _db.get_index_type<account_index>().indices().get<by_name>();
auto itr = idx.find(name);
if (itr != idx.end())
return *itr;
return optional<account_object>();
}
} } // graphene::app

View file

@ -110,6 +110,8 @@ namespace graphene { namespace app {
* This function has semantics identical to @ref get_objects
*/
vector<optional<account_object>> lookup_account_names(const vector<string>& account_names)const;
optional<account_object> get_account_by_name( string name )const;
/**
* @brief Get a list of assets by symbol
* @param asset_symbols Symbols or stringified IDs of the assets to retrieve
@ -515,6 +517,7 @@ FC_API(graphene::app::database_api,
(get_accounts)
(get_assets)
(lookup_account_names)
(get_account_by_name)
(get_account_count)
(lookup_accounts)
(get_full_accounts)