diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 15b632e97..e692f1376 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -100,6 +100,7 @@ class database_api_impl : public std::enable_shared_from_this vector> get_assets(const vector& asset_ids)const; vector list_assets(const string& lower_bound_symbol, uint32_t limit)const; vector> lookup_asset_symbols(const vector& symbols_or_ids)const; + uint64_t get_asset_count()const; // Peerplays vector list_sports() const; @@ -1012,6 +1013,15 @@ vector> database_api_impl::lookup_asset_symbols(const vec return result; } +uint64_t database_api::get_asset_count()const +{ + return my->get_asset_count(); +} + +uint64_t database_api_impl::get_asset_count()const +{ + return _db.get_index_type().indices().size(); +} //////////////////// // Lottery Assets // //////////////////// diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index 6f90938d5..78a9ca1f9 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -342,6 +342,12 @@ class database_api * This function has semantics identical to @ref get_objects */ vector> lookup_asset_symbols(const vector& symbols_or_ids)const; + + /** + * @brief Get assets count + * @return The assets count + */ + uint64_t get_asset_count()const; //////////////////// // Lottery Assets // @@ -727,6 +733,7 @@ FC_API(graphene::app::database_api, (get_assets) (list_assets) (lookup_asset_symbols) + (get_asset_count) // Peerplays (list_sports) diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index 9c47ec490..3059f1794 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -348,6 +348,12 @@ class wallet_api * @returns the list of asset objects, ordered by symbol */ vector list_assets(const string& lowerbound, uint32_t limit)const; + + /** Returns assets count registered on the blockchain. + * + * @returns assets count + */ + uint64_t get_asset_count()const; vector get_lotteries( asset_id_type stop = asset_id_type(), @@ -1925,6 +1931,7 @@ FC_API( graphene::wallet::wallet_api, (list_accounts) (list_account_balances) (list_assets) + (get_asset_count) (import_key) (import_accounts) (import_account_keys) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 726cedaa9..960d84562 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -3424,6 +3424,11 @@ vector wallet_api::list_assets(const string& lowerbound, uint32_t return my->_remote_db->list_assets( lowerbound, limit ); } +uint64_t wallet_api::get_asset_count()const +{ + return my->_remote_db->get_asset_count(); +} + vector wallet_api::get_lotteries( asset_id_type stop, unsigned limit, asset_id_type start )const