#270 get_workers() function in wallet_api
This commit is contained in:
parent
65df816af6
commit
b24a6ac3e2
2 changed files with 55 additions and 0 deletions
|
|
@ -1385,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.
|
||||||
*
|
*
|
||||||
|
|
@ -2673,6 +2679,7 @@ 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)
|
(list_workers)
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
@ -5052,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