GPOS Handle the block missing cases
This commit is contained in:
parent
3bc945aeea
commit
ceba16abc7
2 changed files with 9 additions and 5 deletions
|
|
@ -800,7 +800,11 @@ uint32_t database::get_gpos_current_subperiod()
|
||||||
// variables needed
|
// variables needed
|
||||||
const fc::time_point_sec period_end = period_start + vesting_period;
|
const fc::time_point_sec period_end = period_start + vesting_period;
|
||||||
const auto number_of_subperiods = vesting_period / vesting_subperiod;
|
const auto number_of_subperiods = vesting_period / vesting_subperiod;
|
||||||
const auto now = this->head_block_time();
|
auto now = this->head_block_time();
|
||||||
|
// This might happen due to missing blocks, we really don't want to cause assert failures
|
||||||
|
if(now > period_end) {
|
||||||
|
now = period_end;
|
||||||
|
}
|
||||||
auto seconds_since_period_start = now.sec_since_epoch() - period_start.sec_since_epoch();
|
auto seconds_since_period_start = now.sec_since_epoch() - period_start.sec_since_epoch();
|
||||||
|
|
||||||
FC_ASSERT(period_start <= now && now <= period_end);
|
FC_ASSERT(period_start <= now && now <= period_end);
|
||||||
|
|
@ -926,8 +930,8 @@ void rolling_period_start(database& db)
|
||||||
if(now.sec_since_epoch() >= (period_start + vesting_period))
|
if(now.sec_since_epoch() >= (period_start + vesting_period))
|
||||||
{
|
{
|
||||||
// roll
|
// roll
|
||||||
db.modify(db.get_global_properties(), [now](global_property_object& p) {
|
db.modify(db.get_global_properties(), [period_start, vesting_period](global_property_object& p) {
|
||||||
p.parameters.extensions.value.gpos_period_start = now.sec_since_epoch();
|
p.parameters.extensions.value.gpos_period_start = period_start + vesting_period;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -630,6 +630,7 @@ BOOST_AUTO_TEST_CASE( voting )
|
||||||
generate_blocks( HARDFORK_GPOS_TIME );
|
generate_blocks( HARDFORK_GPOS_TIME );
|
||||||
generate_block();
|
generate_block();
|
||||||
|
|
||||||
|
auto now = HARDFORK_GPOS_TIME;
|
||||||
const auto& core = asset_id_type()(db);
|
const auto& core = asset_id_type()(db);
|
||||||
|
|
||||||
// send some asset to alice and bob
|
// send some asset to alice and bob
|
||||||
|
|
@ -651,7 +652,6 @@ BOOST_AUTO_TEST_CASE( voting )
|
||||||
BOOST_CHECK_EQUAL(db.get_global_properties().parameters.gpos_period_start(), HARDFORK_GPOS_TIME.sec_since_epoch());
|
BOOST_CHECK_EQUAL(db.get_global_properties().parameters.gpos_period_start(), HARDFORK_GPOS_TIME.sec_since_epoch());
|
||||||
|
|
||||||
// update default gpos for test speed
|
// update default gpos for test speed
|
||||||
auto now = db.head_block_time();
|
|
||||||
// 5184000 = 60x60x24x60 = 60 days
|
// 5184000 = 60x60x24x60 = 60 days
|
||||||
// 864000 = 60x60x24x10 = 10 days
|
// 864000 = 60x60x24x10 = 10 days
|
||||||
update_gpos_global(5184000, 864000, now);
|
update_gpos_global(5184000, 864000, now);
|
||||||
|
|
@ -754,7 +754,7 @@ BOOST_AUTO_TEST_CASE( voting )
|
||||||
advance_x_maint(5);
|
advance_x_maint(5);
|
||||||
// a new GPOS period is in but vote from user is before the start. Whoever votes in 6th sub-period, votes will carry
|
// a new GPOS period is in but vote from user is before the start. Whoever votes in 6th sub-period, votes will carry
|
||||||
now = db.head_block_time();
|
now = db.head_block_time();
|
||||||
BOOST_CHECK_EQUAL(db.get_global_properties().parameters.gpos_period_start(), now.sec_since_epoch());
|
BOOST_CHECK_EQUAL(db.get_global_properties().parameters.gpos_period_start(), HARDFORK_GPOS_TIME.sec_since_epoch()+db.get_global_properties().parameters.gpos_period());
|
||||||
|
|
||||||
generate_block();
|
generate_block();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue