Skip to content

Commit

Permalink
#270 get_committee_member_count() function
Browse files Browse the repository at this point in the history
  • Loading branch information
Vlad Dobromyslov committed Feb 7, 2022
1 parent 694ad96 commit b3ee4f5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 9 additions & 0 deletions libraries/app/database_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>
vector<optional<committee_member_object>> get_committee_members(const vector<committee_member_id_type> &committee_member_ids) const;
fc::optional<committee_member_object> get_committee_member_by_account(const std::string account_id_or_name) const;
map<string, committee_member_id_type> lookup_committee_member_accounts(const string &lower_bound_name, uint32_t limit) const;
uint64_t get_committee_member_count() const;

// SON members
vector<optional<son_object>> get_sons(const vector<son_id_type> &son_ids) const;
Expand Down Expand Up @@ -1723,6 +1724,14 @@ map<string, committee_member_id_type> database_api_impl::lookup_committee_member
return committee_members_by_account_name;
}

uint64_t database_api::get_committee_member_count() const {
return my->get_committee_member_count();
}

uint64_t database_api_impl::get_committee_member_count() const {
return _db.get_index_type<committee_member_index>().indices().size();
}

//////////////////////////////////////////////////////////////////////
// //
// SON members //
Expand Down
8 changes: 7 additions & 1 deletion libraries/app/include/graphene/app/database_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,11 @@ class database_api {
*/
map<string, committee_member_id_type> lookup_committee_member_accounts(const string &lower_bound_name, uint32_t limit) const;

/**
* @brief Get the total number of committee_members registered with the blockchain
*/
uint64_t get_committee_member_count() const;

/////////////////
// SON members //
/////////////////
Expand All @@ -625,7 +630,7 @@ class database_api {

/**
* @brief Get the SON owned by a given account
* @param account The ID of the account whose SON should be retrieved
* @param account_id_or_name The ID of the account whose SON should be retrieved
* @return The SON object, or null if the account does not have a SON
*/
fc::optional<son_object> get_son_by_account(const std::string account_id_or_name) const;
Expand Down Expand Up @@ -1094,6 +1099,7 @@ FC_API(graphene::app::database_api,
(get_committee_members)
(get_committee_member_by_account)
(lookup_committee_member_accounts)
(get_committee_member_count)

// SON members
(get_sons)
Expand Down

0 comments on commit b3ee4f5

Please sign in to comment.