#270 functions to unified form
This commit is contained in:
parent
8b611c3f95
commit
339adbb054
4 changed files with 216 additions and 15 deletions
|
|
@ -170,14 +170,17 @@ public:
|
||||||
|
|
||||||
// Witnesses
|
// Witnesses
|
||||||
vector<optional<witness_object>> get_witnesses(const vector<witness_id_type> &witness_ids) const;
|
vector<optional<witness_object>> get_witnesses(const vector<witness_id_type> &witness_ids) const;
|
||||||
|
fc::optional<witness_object> get_witness_by_account_id(account_id_type account) const;
|
||||||
fc::optional<witness_object> get_witness_by_account(const std::string account_id_or_name) const;
|
fc::optional<witness_object> get_witness_by_account(const std::string account_id_or_name) const;
|
||||||
map<string, witness_id_type> lookup_witness_accounts(const string &lower_bound_name, uint32_t limit) const;
|
map<string, witness_id_type> lookup_witness_accounts(const string &lower_bound_name, uint32_t limit) const;
|
||||||
uint64_t get_witness_count() const;
|
uint64_t get_witness_count() const;
|
||||||
|
|
||||||
// Committee members
|
// Committee members
|
||||||
vector<optional<committee_member_object>> get_committee_members(const vector<committee_member_id_type> &committee_member_ids) const;
|
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_id(account_id_type account) const;
|
||||||
fc::optional<committee_member_object> get_committee_member_by_account(const std::string account_id_or_name) 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;
|
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
|
// SON members
|
||||||
vector<optional<son_object>> get_sons(const vector<son_id_type> &son_ids) const;
|
vector<optional<son_object>> get_sons(const vector<son_id_type> &son_ids) const;
|
||||||
|
|
@ -200,7 +203,10 @@ public:
|
||||||
|
|
||||||
// Workers
|
// Workers
|
||||||
vector<optional<worker_object>> get_workers(const vector<worker_id_type> &witness_ids) const;
|
vector<optional<worker_object>> get_workers(const vector<worker_id_type> &witness_ids) const;
|
||||||
|
vector<worker_object> get_workers_by_account_id(account_id_type account) const;
|
||||||
vector<worker_object> get_workers_by_account(const std::string account_id_or_name) const;
|
vector<worker_object> get_workers_by_account(const std::string account_id_or_name) const;
|
||||||
|
map<string, worker_id_type> lookup_worker_accounts(const string &lower_bound_name, uint32_t limit) const;
|
||||||
|
uint64_t get_worker_count() const;
|
||||||
|
|
||||||
// Votes
|
// Votes
|
||||||
vector<variant> lookup_vote_ids(const vector<vote_id_type> &votes) const;
|
vector<variant> lookup_vote_ids(const vector<vote_id_type> &votes) const;
|
||||||
|
|
@ -292,6 +298,8 @@ public:
|
||||||
uint32_t api_limit_lookup_accounts = 1000;
|
uint32_t api_limit_lookup_accounts = 1000;
|
||||||
uint32_t api_limit_lookup_witness_accounts = 1000;
|
uint32_t api_limit_lookup_witness_accounts = 1000;
|
||||||
uint32_t api_limit_lookup_committee_member_accounts = 1000;
|
uint32_t api_limit_lookup_committee_member_accounts = 1000;
|
||||||
|
uint32_t api_limit_lookup_son_accounts = 1000;
|
||||||
|
uint32_t api_limit_lookup_worker_accounts = 1000;
|
||||||
uint32_t api_limit_get_trade_history = 100;
|
uint32_t api_limit_get_trade_history = 100;
|
||||||
uint32_t api_limit_get_trade_history_by_sequence = 100;
|
uint32_t api_limit_get_trade_history_by_sequence = 100;
|
||||||
|
|
||||||
|
|
@ -1611,17 +1619,25 @@ vector<optional<witness_object>> database_api_impl::get_witnesses(const vector<w
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fc::optional<witness_object> database_api::get_witness_by_account_id(account_id_type account) const {
|
||||||
|
return my->get_witness_by_account_id(account);
|
||||||
|
}
|
||||||
|
|
||||||
|
fc::optional<witness_object> database_api_impl::get_witness_by_account_id(account_id_type account) const {
|
||||||
|
const auto &idx = _db.get_index_type<witness_index>().indices().get<by_account>();
|
||||||
|
auto itr = idx.find(account);
|
||||||
|
if (itr != idx.end())
|
||||||
|
return *itr;
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
fc::optional<witness_object> database_api::get_witness_by_account(const std::string account_id_or_name) const {
|
fc::optional<witness_object> database_api::get_witness_by_account(const std::string account_id_or_name) const {
|
||||||
return my->get_witness_by_account(account_id_or_name);
|
return my->get_witness_by_account(account_id_or_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
fc::optional<witness_object> database_api_impl::get_witness_by_account(const std::string account_id_or_name) const {
|
fc::optional<witness_object> database_api_impl::get_witness_by_account(const std::string account_id_or_name) const {
|
||||||
const auto &idx = _db.get_index_type<witness_index>().indices().get<by_account>();
|
|
||||||
const account_id_type account = get_account_from_string(account_id_or_name)->id;
|
const account_id_type account = get_account_from_string(account_id_or_name)->id;
|
||||||
auto itr = idx.find(account);
|
return get_witness_by_account_id(account);
|
||||||
if (itr != idx.end())
|
|
||||||
return *itr;
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
map<string, witness_id_type> database_api::lookup_witness_accounts(const string &lower_bound_name, uint32_t limit) const {
|
map<string, witness_id_type> database_api::lookup_witness_accounts(const string &lower_bound_name, uint32_t limit) const {
|
||||||
|
|
@ -1682,17 +1698,25 @@ vector<optional<committee_member_object>> database_api_impl::get_committee_membe
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fc::optional<committee_member_object> database_api::get_committee_member_by_account_id(account_id_type account) const {
|
||||||
|
return my->get_committee_member_by_account_id(account);
|
||||||
|
}
|
||||||
|
|
||||||
|
fc::optional<committee_member_object> database_api_impl::get_committee_member_by_account_id(account_id_type account) const {
|
||||||
|
const auto &idx = _db.get_index_type<committee_member_index>().indices().get<by_account>();
|
||||||
|
auto itr = idx.find(account);
|
||||||
|
if (itr != idx.end())
|
||||||
|
return *itr;
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
fc::optional<committee_member_object> database_api::get_committee_member_by_account(const std::string account_id_or_name) const {
|
fc::optional<committee_member_object> database_api::get_committee_member_by_account(const std::string account_id_or_name) const {
|
||||||
return my->get_committee_member_by_account(account_id_or_name);
|
return my->get_committee_member_by_account(account_id_or_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
fc::optional<committee_member_object> database_api_impl::get_committee_member_by_account(const std::string account_id_or_name) const {
|
fc::optional<committee_member_object> database_api_impl::get_committee_member_by_account(const std::string account_id_or_name) const {
|
||||||
const auto &idx = _db.get_index_type<committee_member_index>().indices().get<by_account>();
|
|
||||||
const account_id_type account = get_account_from_string(account_id_or_name)->id;
|
const account_id_type account = get_account_from_string(account_id_or_name)->id;
|
||||||
auto itr = idx.find(account);
|
return get_committee_member_by_account_id(account);
|
||||||
if (itr != idx.end())
|
|
||||||
return *itr;
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
map<string, committee_member_id_type> database_api::lookup_committee_member_accounts(const string &lower_bound_name, uint32_t limit) const {
|
map<string, committee_member_id_type> database_api::lookup_committee_member_accounts(const string &lower_bound_name, uint32_t limit) const {
|
||||||
|
|
@ -1723,6 +1747,14 @@ map<string, committee_member_id_type> database_api_impl::lookup_committee_member
|
||||||
return committee_members_by_account_name;
|
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 //
|
// SON members //
|
||||||
|
|
@ -1771,7 +1803,10 @@ map<string, son_id_type> database_api::lookup_son_accounts(const string &lower_b
|
||||||
}
|
}
|
||||||
|
|
||||||
map<string, son_id_type> database_api_impl::lookup_son_accounts(const string &lower_bound_name, uint32_t limit) const {
|
map<string, son_id_type> database_api_impl::lookup_son_accounts(const string &lower_bound_name, uint32_t limit) const {
|
||||||
FC_ASSERT(limit <= 1000);
|
FC_ASSERT(limit <= api_limit_lookup_son_accounts,
|
||||||
|
"Number of querying accounts can not be greater than ${configured_limit}",
|
||||||
|
("configured_limit", api_limit_lookup_son_accounts));
|
||||||
|
|
||||||
const auto &sons_by_id = _db.get_index_type<son_index>().indices().get<by_id>();
|
const auto &sons_by_id = _db.get_index_type<son_index>().indices().get<by_id>();
|
||||||
|
|
||||||
// we want to order sons by account name, but that name is in the account object
|
// we want to order sons by account name, but that name is in the account object
|
||||||
|
|
@ -1927,10 +1962,22 @@ vector<optional<worker_object>> database_api::get_workers(const vector<worker_id
|
||||||
return my->get_workers(worker_ids);
|
return my->get_workers(worker_ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vector<worker_object> database_api::get_workers_by_account_id(account_id_type account) const {
|
||||||
|
return my->get_workers_by_account_id(account);
|
||||||
|
}
|
||||||
|
|
||||||
vector<worker_object> database_api::get_workers_by_account(const std::string account_id_or_name) const {
|
vector<worker_object> database_api::get_workers_by_account(const std::string account_id_or_name) const {
|
||||||
return my->get_workers_by_account(account_id_or_name);
|
return my->get_workers_by_account(account_id_or_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
map<string, worker_id_type> database_api::lookup_worker_accounts(const string &lower_bound_name, uint32_t limit) const {
|
||||||
|
return my->lookup_worker_accounts(lower_bound_name, limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t database_api::get_worker_count() const {
|
||||||
|
return my->get_worker_count();
|
||||||
|
}
|
||||||
|
|
||||||
vector<optional<worker_object>> database_api_impl::get_workers(const vector<worker_id_type> &worker_ids) const {
|
vector<optional<worker_object>> database_api_impl::get_workers(const vector<worker_id_type> &worker_ids) const {
|
||||||
vector<optional<worker_object>> result;
|
vector<optional<worker_object>> result;
|
||||||
result.reserve(worker_ids.size());
|
result.reserve(worker_ids.size());
|
||||||
|
|
@ -1943,9 +1990,8 @@ vector<optional<worker_object>> database_api_impl::get_workers(const vector<work
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<worker_object> database_api_impl::get_workers_by_account(const std::string account_id_or_name) const {
|
vector<worker_object> database_api_impl::get_workers_by_account_id(account_id_type account) const {
|
||||||
const auto &idx = _db.get_index_type<worker_index>().indices().get<by_account>();
|
const auto &idx = _db.get_index_type<worker_index>().indices().get<by_account>();
|
||||||
const account_id_type account = get_account_from_string(account_id_or_name)->id;
|
|
||||||
auto itr = idx.find(account);
|
auto itr = idx.find(account);
|
||||||
vector<worker_object> result;
|
vector<worker_object> result;
|
||||||
|
|
||||||
|
|
@ -1957,6 +2003,40 @@ vector<worker_object> database_api_impl::get_workers_by_account(const std::strin
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vector<worker_object> database_api_impl::get_workers_by_account(const std::string account_id_or_name) const {
|
||||||
|
const account_id_type account = get_account_from_string(account_id_or_name)->id;
|
||||||
|
return get_workers_by_account_id(account);
|
||||||
|
}
|
||||||
|
|
||||||
|
map<string, worker_id_type> database_api_impl::lookup_worker_accounts(const string &lower_bound_name, uint32_t limit) const {
|
||||||
|
FC_ASSERT(limit <= api_limit_lookup_worker_accounts,
|
||||||
|
"Number of querying accounts can not be greater than ${configured_limit}",
|
||||||
|
("configured_limit", api_limit_lookup_worker_accounts));
|
||||||
|
|
||||||
|
const auto &workers_by_id = _db.get_index_type<worker_index>().indices().get<by_id>();
|
||||||
|
|
||||||
|
// we want to order workers by account name, but that name is in the account object
|
||||||
|
// so the worker_index doesn't have a quick way to access it.
|
||||||
|
// get all the names and look them all up, sort them, then figure out what
|
||||||
|
// records to return. This could be optimized, but we expect the
|
||||||
|
// number of witnesses to be few and the frequency of calls to be rare
|
||||||
|
std::map<std::string, worker_id_type> workers_by_account_name;
|
||||||
|
for (const worker_object &worker : workers_by_id)
|
||||||
|
if (auto account_iter = _db.find(worker.worker_account))
|
||||||
|
if (account_iter->name >= lower_bound_name) // we can ignore anything below lower_bound_name
|
||||||
|
workers_by_account_name.insert(std::make_pair(account_iter->name, worker.id));
|
||||||
|
|
||||||
|
auto end_iter = workers_by_account_name.begin();
|
||||||
|
while (end_iter != workers_by_account_name.end() && limit--)
|
||||||
|
++end_iter;
|
||||||
|
workers_by_account_name.erase(end_iter, workers_by_account_name.end());
|
||||||
|
return workers_by_account_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t database_api_impl::get_worker_count() const {
|
||||||
|
return _db.get_index_type<worker_index>().indices().size();
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// //
|
// //
|
||||||
// Votes //
|
// Votes //
|
||||||
|
|
|
||||||
|
|
@ -560,6 +560,13 @@ public:
|
||||||
* @param account The ID of the account whose witness should be retrieved
|
* @param account The ID of the account whose witness should be retrieved
|
||||||
* @return The witness object, or null if the account does not have a witness
|
* @return The witness object, or null if the account does not have a witness
|
||||||
*/
|
*/
|
||||||
|
fc::optional<witness_object> get_witness_by_account_id(account_id_type account) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the witness owned by a given account
|
||||||
|
* @param account_id_or_name The ID or name of the account whose witness should be retrieved
|
||||||
|
* @return The witness object, or null if the account does not have a witness
|
||||||
|
*/
|
||||||
fc::optional<witness_object> get_witness_by_account(const std::string account_name_or_id) const;
|
fc::optional<witness_object> get_witness_by_account(const std::string account_name_or_id) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -588,6 +595,13 @@ public:
|
||||||
*/
|
*/
|
||||||
vector<optional<committee_member_object>> get_committee_members(const vector<committee_member_id_type> &committee_member_ids) const;
|
vector<optional<committee_member_object>> get_committee_members(const vector<committee_member_id_type> &committee_member_ids) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the committee_member owned by a given account
|
||||||
|
* @param account The ID of the account whose committee_member should be retrieved
|
||||||
|
* @return The committee_member object, or null if the account does not have a committee_member
|
||||||
|
*/
|
||||||
|
fc::optional<committee_member_object> get_committee_member_by_account_id(account_id_type account) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the committee_member owned by a given account
|
* @brief Get the committee_member owned by a given account
|
||||||
* @param account_id_or_name The ID or name of the account whose committee_member should be retrieved
|
* @param account_id_or_name The ID or name of the account whose committee_member should be retrieved
|
||||||
|
|
@ -603,6 +617,11 @@ public:
|
||||||
*/
|
*/
|
||||||
map<string, committee_member_id_type> lookup_committee_member_accounts(const string &lower_bound_name, uint32_t limit) const;
|
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 //
|
// SON members //
|
||||||
/////////////////
|
/////////////////
|
||||||
|
|
@ -625,7 +644,7 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the SON owned by a given account
|
* @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
|
* @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;
|
fc::optional<son_object> get_son_by_account(const std::string account_id_or_name) const;
|
||||||
|
|
@ -722,11 +741,31 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Return the worker objects associated with this account.
|
* @brief Return the worker objects associated with this account.
|
||||||
* @param account_id_or_name The ID or name of the account whose worker should be retrieved
|
* @param account The ID of the account whose workers should be retrieved
|
||||||
|
* @return The worker object or null if the account does not have a worker
|
||||||
|
*/
|
||||||
|
vector<worker_object> get_workers_by_account_id(account_id_type account) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return the worker objects associated with this account.
|
||||||
|
* @param account_id_or_name The ID or name of the account whose workers should be retrieved
|
||||||
* @return The worker object or null if the account does not have a worker
|
* @return The worker object or null if the account does not have a worker
|
||||||
*/
|
*/
|
||||||
vector<worker_object> get_workers_by_account(const std::string account_id_or_name) const;
|
vector<worker_object> get_workers_by_account(const std::string account_id_or_name) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get names and IDs for registered workers
|
||||||
|
* @param lower_bound_name Lower bound of the first name to return
|
||||||
|
* @param limit Maximum number of results to return -- must not exceed 1000
|
||||||
|
* @return Map of worker names to corresponding IDs
|
||||||
|
*/
|
||||||
|
map<string, worker_id_type> lookup_worker_accounts(const string &lower_bound_name, uint32_t limit) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the total number of workers registered with the blockchain
|
||||||
|
*/
|
||||||
|
uint64_t get_worker_count() const;
|
||||||
|
|
||||||
///////////
|
///////////
|
||||||
// Votes //
|
// Votes //
|
||||||
///////////
|
///////////
|
||||||
|
|
@ -1086,14 +1125,17 @@ FC_API(graphene::app::database_api,
|
||||||
|
|
||||||
// Witnesses
|
// Witnesses
|
||||||
(get_witnesses)
|
(get_witnesses)
|
||||||
|
(get_witness_by_account_id)
|
||||||
(get_witness_by_account)
|
(get_witness_by_account)
|
||||||
(lookup_witness_accounts)
|
(lookup_witness_accounts)
|
||||||
(get_witness_count)
|
(get_witness_count)
|
||||||
|
|
||||||
// Committee members
|
// Committee members
|
||||||
(get_committee_members)
|
(get_committee_members)
|
||||||
|
(get_committee_member_by_account_id)
|
||||||
(get_committee_member_by_account)
|
(get_committee_member_by_account)
|
||||||
(lookup_committee_member_accounts)
|
(lookup_committee_member_accounts)
|
||||||
|
(get_committee_member_count)
|
||||||
|
|
||||||
// SON members
|
// SON members
|
||||||
(get_sons)
|
(get_sons)
|
||||||
|
|
@ -1116,7 +1158,10 @@ FC_API(graphene::app::database_api,
|
||||||
|
|
||||||
// Workers
|
// Workers
|
||||||
(get_workers)
|
(get_workers)
|
||||||
|
(get_workers_by_account_id)
|
||||||
(get_workers_by_account)
|
(get_workers_by_account)
|
||||||
|
(lookup_worker_accounts)
|
||||||
|
(get_worker_count)
|
||||||
|
|
||||||
// Votes
|
// Votes
|
||||||
(lookup_vote_ids)
|
(lookup_vote_ids)
|
||||||
|
|
|
||||||
|
|
@ -1346,6 +1346,21 @@ class wallet_api
|
||||||
*/
|
*/
|
||||||
map<string, committee_member_id_type> list_committee_members(const string& lowerbound, uint32_t limit);
|
map<string, committee_member_id_type> list_committee_members(const string& lowerbound, uint32_t limit);
|
||||||
|
|
||||||
|
/** Lists all workers in the blockchain.
|
||||||
|
* This returns a list of all account names that own worker, and the associated worker id,
|
||||||
|
* sorted by name. This lists workers whether they are currently voted in or not.
|
||||||
|
*
|
||||||
|
* Use the \c lowerbound and limit parameters to page through the list. To retrieve all workers,
|
||||||
|
* start by setting \c lowerbound to the empty string \c "", and then each iteration, pass
|
||||||
|
* the last worker name returned as the \c lowerbound for the next \c list_workers() call.
|
||||||
|
*
|
||||||
|
* @param lowerbound the name of the first worker to return. If the named worker does not exist,
|
||||||
|
* the list will start at the worker that comes after \c lowerbound
|
||||||
|
* @param limit the maximum number of worker to return (max: 1000)
|
||||||
|
* @returns a list of worker mapping worker names to worker ids
|
||||||
|
*/
|
||||||
|
map<string, worker_id_type> list_workers(const string& lowerbound, uint32_t limit);
|
||||||
|
|
||||||
/** Returns information about the given SON.
|
/** Returns information about the given SON.
|
||||||
* @param owner_account the name or id of the SON account owner, or the id of the SON
|
* @param owner_account the name or id of the SON account owner, or the id of the SON
|
||||||
* @returns the information about the SON stored in the block chain
|
* @returns the information about the SON stored in the block chain
|
||||||
|
|
@ -1370,6 +1385,12 @@ class wallet_api
|
||||||
*/
|
*/
|
||||||
committee_member_object get_committee_member(string owner_account);
|
committee_member_object get_committee_member(string owner_account);
|
||||||
|
|
||||||
|
/** Returns information about the given worker.
|
||||||
|
* @param owner_account the name or id of the worker account owner, or the id of the worker
|
||||||
|
* @returns the information about the workers stored in the block chain
|
||||||
|
*/
|
||||||
|
vector<worker_object> get_workers(string owner_account);
|
||||||
|
|
||||||
|
|
||||||
/** Creates a SON object owned by the given account.
|
/** Creates a SON object owned by the given account.
|
||||||
*
|
*
|
||||||
|
|
@ -2658,8 +2679,10 @@ FC_API( graphene::wallet::wallet_api,
|
||||||
(get_witness)
|
(get_witness)
|
||||||
(is_witness)
|
(is_witness)
|
||||||
(get_committee_member)
|
(get_committee_member)
|
||||||
|
(get_workers)
|
||||||
(list_witnesses)
|
(list_witnesses)
|
||||||
(list_committee_members)
|
(list_committee_members)
|
||||||
|
(list_workers)
|
||||||
(create_son)
|
(create_son)
|
||||||
(try_create_son)
|
(try_create_son)
|
||||||
(update_son)
|
(update_son)
|
||||||
|
|
|
||||||
|
|
@ -1961,6 +1961,49 @@ public:
|
||||||
FC_CAPTURE_AND_RETHROW( (owner_account) )
|
FC_CAPTURE_AND_RETHROW( (owner_account) )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vector<worker_object> get_workers(string owner_account)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
fc::optional<worker_id_type> worker_id = maybe_id<worker_id_type>(owner_account);
|
||||||
|
if (worker_id)
|
||||||
|
{
|
||||||
|
std::vector<worker_id_type> ids_to_get;
|
||||||
|
ids_to_get.push_back(*worker_id);
|
||||||
|
std::vector<fc::optional<worker_object>> worker_objects = _remote_db->get_workers(ids_to_get);
|
||||||
|
|
||||||
|
if(!worker_objects.empty()) {
|
||||||
|
std::vector<worker_object> result;
|
||||||
|
for (const auto &worker_object : worker_objects) {
|
||||||
|
if (worker_object)
|
||||||
|
result.emplace_back(*worker_object);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
FC_THROW("No workers is registered for id ${id}", ("id", owner_account));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// then maybe it's the owner account
|
||||||
|
try
|
||||||
|
{
|
||||||
|
std::string owner_account_id = account_id_to_string(get_account_id(owner_account));
|
||||||
|
auto workers = _remote_db->get_workers_by_account(owner_account_id);
|
||||||
|
if (!workers.empty())
|
||||||
|
return workers;
|
||||||
|
else
|
||||||
|
FC_THROW("No workers is registered for account ${account}", ("account", owner_account));
|
||||||
|
}
|
||||||
|
catch (const fc::exception&)
|
||||||
|
{
|
||||||
|
FC_THROW("No account or worker named ${account}", ("account", owner_account));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FC_CAPTURE_AND_RETHROW( (owner_account) )
|
||||||
|
}
|
||||||
|
|
||||||
bool is_witness(string owner_account)
|
bool is_witness(string owner_account)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
@ -5027,6 +5070,11 @@ map<string,committee_member_id_type> wallet_api::list_committee_members(const st
|
||||||
return my->_remote_db->lookup_committee_member_accounts(lowerbound, limit);
|
return my->_remote_db->lookup_committee_member_accounts(lowerbound, limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
map<string, worker_id_type> wallet_api::list_workers(const string& lowerbound, uint32_t limit)
|
||||||
|
{
|
||||||
|
return my->_remote_db->lookup_worker_accounts(lowerbound, limit);
|
||||||
|
}
|
||||||
|
|
||||||
son_object wallet_api::get_son(string owner_account)
|
son_object wallet_api::get_son(string owner_account)
|
||||||
{
|
{
|
||||||
return my->get_son(owner_account);
|
return my->get_son(owner_account);
|
||||||
|
|
@ -5047,6 +5095,11 @@ committee_member_object wallet_api::get_committee_member(string owner_account)
|
||||||
return my->get_committee_member(owner_account);
|
return my->get_committee_member(owner_account);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vector<worker_object> wallet_api::get_workers(string owner_account)
|
||||||
|
{
|
||||||
|
return my->get_workers(owner_account);
|
||||||
|
}
|
||||||
|
|
||||||
signed_transaction wallet_api::create_vesting_balance(string owner_account,
|
signed_transaction wallet_api::create_vesting_balance(string owner_account,
|
||||||
string amount,
|
string amount,
|
||||||
string asset_symbol,
|
string asset_symbol,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue