Allow voting for son, only if GPOS vesting balance available

This commit is contained in:
pbattu123 2020-03-16 18:24:28 -03:00
parent d22544657f
commit 3ffcd4fdd0

View file

@ -2589,6 +2589,13 @@ public:
bool approve,
bool broadcast /* = false */)
{ try {
std::vector<vesting_balance_object_with_info> vbo_info = get_vesting_balances(voting_account);
std::vector<vesting_balance_object_with_info>::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 vote for the SON account", ("account", voting_account)("TOKEN", GRAPHENE_SYMBOL));
account_object voting_account_object = get_account(voting_account);
account_id_type son_account_id = get_account_id(son);
fc::optional<son_object> son_obj = _remote_db->get_son_by_account(son_account_id);