hf protection for creating gpos balances in proposals

This commit is contained in:
Alfredo 2019-01-03 14:38:31 -03:00
parent d468b146e8
commit 83ea345042
2 changed files with 8 additions and 6 deletions

View file

@ -735,7 +735,7 @@ double calculate_vesting_factor(const database& d, const account_object& stake_a
const auto &gpo = d.get_global_properties();
const auto vesting_period = gpo.parameters.gpos_period;
const auto vesting_subperiod = gpo.parameters.gpos_subperiod;
const auto period_start = time_point_sec(gpo.parameters.gpos_period_start);
const auto period_start = gpo.parameters.gpos_period_start;
// variables needed
const fc::time_point_sec period_end = period_start + vesting_period;
@ -761,8 +761,6 @@ double calculate_vesting_factor(const database& d, const account_object& stake_a
// coefficient calculation is: (n-1)/number_of_subperiods
double n = number_of_subperiods + 1;
if (current_period > number_of_subperiods) // exception maybe?
return 0;
auto period = std::find_if(period_list.begin(), period_list.end(),[&](uint32_t p) {
return (p == current_period);
@ -1393,10 +1391,10 @@ void database::perform_chain_maintenance(const signed_block& next_block, const g
distribute_fba_balances(*this);
create_buyback_orders(*this);
process_dividend_assets(*this);
rolling_period_start(*this);
process_dividend_assets(*this);
struct vote_tally_helper {
database& d;
const global_property_object& props;
@ -1472,7 +1470,6 @@ void database::perform_chain_maintenance(const signed_block& next_block, const g
auto vesting_factor = calculate_vesting_factor(d, stake_account);
voting_stake = (uint64_t)floor(voting_stake * vesting_factor);
}
else
{

View file

@ -135,6 +135,11 @@ struct proposal_operation_hardfork_visitor
FC_ASSERT( block_time >= HARDFORK_1000_TIME, "event_update_status_operation not allowed yet!" );
}
void operator()(const vesting_balance_create_operation &vbco) const {
if(block_time < HARDFORK_GPOS_TIME)
FC_ASSERT( vbco.balance_type == vesting_balance_type::unspecified, "balance_type in vesting create not allowed yet!" );
}
// loop and self visit in proposals
void operator()(const proposal_create_operation &v) const {
for (const op_wrapper &op : v.proposed_ops)