list_active_sons api call implementation
This commit is contained in:
parent
e4eb3e6ce3
commit
22f76a04c0
2 changed files with 38 additions and 0 deletions
|
|
@ -1363,6 +1363,13 @@ class wallet_api
|
||||||
*/
|
*/
|
||||||
map<string, son_id_type> list_sons(const string& lowerbound, uint32_t limit);
|
map<string, son_id_type> list_sons(const string& lowerbound, uint32_t limit);
|
||||||
|
|
||||||
|
/** Lists active at the moment SONs.
|
||||||
|
* This returns a list of all account names that own active SON, and the associated SON id,
|
||||||
|
* sorted by name.
|
||||||
|
* @returns a list of active SONs mapping SON names to SON ids
|
||||||
|
*/
|
||||||
|
map<string, son_id_type> list_active_sons();
|
||||||
|
|
||||||
/** Creates a witness object owned by the given account.
|
/** Creates a witness object owned by the given account.
|
||||||
*
|
*
|
||||||
* An account can have at most one witness object.
|
* An account can have at most one witness object.
|
||||||
|
|
|
||||||
|
|
@ -1932,6 +1932,32 @@ public:
|
||||||
return sign_transaction( tx, broadcast );
|
return sign_transaction( tx, broadcast );
|
||||||
} FC_CAPTURE_AND_RETHROW( (owner_account)(broadcast) ) }
|
} FC_CAPTURE_AND_RETHROW( (owner_account)(broadcast) ) }
|
||||||
|
|
||||||
|
map<string, son_id_type> list_active_sons()
|
||||||
|
{ try {
|
||||||
|
global_property_object gpo = get_global_properties();
|
||||||
|
std::vector<fc::optional<son_object>> son_objects =
|
||||||
|
_remote_db->get_sons(gpo.active_sons);
|
||||||
|
vector<account_id_type> owners;
|
||||||
|
owners.resize(son_objects.size());
|
||||||
|
std::transform(son_objects.begin(), son_objects.end(), owners.begin(),
|
||||||
|
[](const fc::optional<son_object>& obj) {
|
||||||
|
if(!obj)
|
||||||
|
FC_THROW("Invalid active SONs list in global properties.");
|
||||||
|
return obj->son_account;
|
||||||
|
});
|
||||||
|
vector<fc::optional<account_object>> accs = _remote_db->get_accounts(owners);
|
||||||
|
map<string, son_id_type> result;
|
||||||
|
std::transform(accs.begin(), accs.end(), gpo.active_sons.begin(),
|
||||||
|
std::inserter(result, result.end()),
|
||||||
|
[](fc::optional<account_object>& acct,
|
||||||
|
son_id_type& sid) {
|
||||||
|
if(!acct)
|
||||||
|
FC_THROW("Invalid active SONs list in global properties.");
|
||||||
|
return std::make_pair<string, son_id_type>(string(acct->name), std::move(sid));
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
} FC_CAPTURE_AND_RETHROW() }
|
||||||
|
|
||||||
signed_transaction create_witness(string owner_account,
|
signed_transaction create_witness(string owner_account,
|
||||||
string url,
|
string url,
|
||||||
bool broadcast /* = false */)
|
bool broadcast /* = false */)
|
||||||
|
|
@ -4303,6 +4329,11 @@ map<string, son_id_type> wallet_api::list_sons(const string& lowerbound, uint32_
|
||||||
return my->_remote_db->lookup_son_accounts(lowerbound, limit);
|
return my->_remote_db->lookup_son_accounts(lowerbound, limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
map<string, son_id_type> wallet_api::list_active_sons()
|
||||||
|
{
|
||||||
|
return my->list_active_sons();
|
||||||
|
}
|
||||||
|
|
||||||
signed_transaction wallet_api::create_witness(string owner_account,
|
signed_transaction wallet_api::create_witness(string owner_account,
|
||||||
string url,
|
string url,
|
||||||
bool broadcast /* = false */)
|
bool broadcast /* = false */)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue