Merge branch 'feature/573-vote_recharge_gpos' into 'develop'
#573 - add vote_recharge_gpos function See merge request PBSA/peerplays!261
This commit is contained in:
commit
24b0327eb6
3 changed files with 49 additions and 4 deletions
|
|
@ -2197,7 +2197,7 @@ vector<variant> database_api_impl::lookup_vote_ids(const vector<vote_id_type> &v
|
|||
case vote_id_type::committee: {
|
||||
auto itr = committee_idx.find(id);
|
||||
if (itr != committee_idx.end())
|
||||
result.emplace_back( variant( *itr, 2 ) ); // Depth of committee_member_object is 1, add 1 to be safe
|
||||
result.emplace_back(variant(*itr, 2)); // Depth of committee_member_object is 1, add 1 to be safe
|
||||
else
|
||||
result.emplace_back(variant());
|
||||
break;
|
||||
|
|
@ -2205,7 +2205,7 @@ vector<variant> database_api_impl::lookup_vote_ids(const vector<vote_id_type> &v
|
|||
case vote_id_type::witness: {
|
||||
auto itr = witness_idx.find(id);
|
||||
if (itr != witness_idx.end())
|
||||
result.emplace_back( variant( *itr, 2 ) ); // Depth of witness_object is 1, add 1 here to be safe
|
||||
result.emplace_back(variant(*itr, 2)); // Depth of witness_object is 1, add 1 here to be safe
|
||||
else
|
||||
result.emplace_back(variant());
|
||||
break;
|
||||
|
|
@ -2213,13 +2213,13 @@ vector<variant> database_api_impl::lookup_vote_ids(const vector<vote_id_type> &v
|
|||
case vote_id_type::worker: {
|
||||
auto itr = for_worker_idx.find(id);
|
||||
if (itr != for_worker_idx.end()) {
|
||||
result.emplace_back( variant( *itr, 4 ) ); // Depth of worker_object is 3, add 1 here to be safe.
|
||||
result.emplace_back(variant(*itr, 4)); // Depth of worker_object is 3, add 1 here to be safe.
|
||||
// If we want to extract the balance object inside,
|
||||
// need to increase this value
|
||||
} else {
|
||||
auto itr = against_worker_idx.find(id);
|
||||
if (itr != against_worker_idx.end()) {
|
||||
result.emplace_back( variant( *itr, 4 ) ); // Depth of worker_object is 3, add 1 here to be safe.
|
||||
result.emplace_back(variant(*itr, 4)); // Depth of worker_object is 3, add 1 here to be safe.
|
||||
// If we want to extract the balance object inside,
|
||||
// need to increase this value
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1990,6 +1990,7 @@ class wallet_api
|
|||
std::vector<std::string> witnesses_to_reject,
|
||||
uint16_t desired_number_of_witnesses,
|
||||
bool broadcast = false);
|
||||
|
||||
/** Set the voting proxy for an account.
|
||||
*
|
||||
* If a user does not wish to take an active part in voting, they can choose
|
||||
|
|
@ -2037,6 +2038,18 @@ class wallet_api
|
|||
uint16_t desired_number_of_committee_members,
|
||||
bool broadcast = false);
|
||||
|
||||
/** Vote recharge gpos.
|
||||
*
|
||||
* Explicit voting recharge function that is used solely when the user wishes to recharge their GPOS voting power
|
||||
* without changing their voting slate
|
||||
*
|
||||
* @param voting_account the name or id of the account who is voting with their shares
|
||||
* @param broadcast true if you wish to broadcast the transaction
|
||||
* @return the signed transaction changing your vote for the given SON
|
||||
*/
|
||||
signed_transaction vote_recharge_gpos(string voting_account,
|
||||
bool broadcast = false);
|
||||
|
||||
/** Signs a transaction.
|
||||
*
|
||||
* Given a fully-formed transaction that is only lacking signatures, this signs
|
||||
|
|
@ -2896,6 +2909,7 @@ FC_API( graphene::wallet::wallet_api,
|
|||
(update_witness_votes)
|
||||
(set_voting_proxy)
|
||||
(set_desired_witness_and_committee_member_count)
|
||||
(vote_recharge_gpos)
|
||||
(get_account)
|
||||
(get_account_id)
|
||||
(get_block)
|
||||
|
|
|
|||
|
|
@ -3101,6 +3101,31 @@ public:
|
|||
return sign_transaction( tx, broadcast );
|
||||
} FC_CAPTURE_AND_RETHROW( (account_to_modify)(desired_number_of_witnesses)(desired_number_of_committee_members)(broadcast) ) }
|
||||
|
||||
signed_transaction vote_recharge_gpos(string voting_account,
|
||||
bool broadcast /* = false */)
|
||||
{ try {
|
||||
|
||||
const std::vector<vesting_balance_object_with_info> vbo_info = get_vesting_balances(voting_account);
|
||||
std::vector<vesting_balance_object_with_info>::const_iterator vbo_iter;
|
||||
vbo_iter = std::find_if(vbo_info.begin(), vbo_info.end(), [](vesting_balance_object_with_info const& obj){return obj.balance_type == vesting_balance_type::gpos;});
|
||||
if( vbo_info.size() == 0 || vbo_iter == vbo_info.end())
|
||||
FC_THROW("Account ${account} has no core Token ${TOKEN} vested and will not be allowed to recharge the votes", ("account", voting_account)("TOKEN", GRAPHENE_SYMBOL));
|
||||
|
||||
const account_object voting_account_object = get_account(voting_account);
|
||||
|
||||
account_update_operation account_update_op;
|
||||
account_update_op.account = voting_account_object.id;
|
||||
account_update_op.new_options = voting_account_object.options;
|
||||
account_update_op.extensions.value.update_last_voting_time = true; //Allow user to vote in each sub-period (Update voting time, which is reference in calculating VF)
|
||||
|
||||
signed_transaction tx;
|
||||
tx.operations.push_back( account_update_op );
|
||||
set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees);
|
||||
tx.validate();
|
||||
|
||||
return sign_transaction( tx, broadcast );
|
||||
} FC_CAPTURE_AND_RETHROW( (voting_account)(broadcast) ) }
|
||||
|
||||
signed_transaction sign_transaction(signed_transaction tx, bool broadcast = false)
|
||||
{
|
||||
set<public_key_type> pks = _remote_db->get_potential_signatures(tx);
|
||||
|
|
@ -5610,6 +5635,12 @@ signed_transaction wallet_api::set_desired_witness_and_committee_member_count(st
|
|||
desired_number_of_committee_members, broadcast);
|
||||
}
|
||||
|
||||
signed_transaction wallet_api::vote_recharge_gpos(string voting_account,
|
||||
bool broadcast /* = false */)
|
||||
{
|
||||
return my->vote_recharge_gpos(voting_account, broadcast);
|
||||
}
|
||||
|
||||
void wallet_api::set_wallet_filename(string wallet_filename)
|
||||
{
|
||||
my->_wallet_filename = wallet_filename;
|
||||
|
|
|
|||
Loading…
Reference in a new issue