From 6b533828db53029702bf1fc690474096b0f54e75 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Mon, 31 Dec 2018 18:20:48 -0300 Subject: [PATCH] implement rolling_period_start function --- libraries/chain/db_maint.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/libraries/chain/db_maint.cpp b/libraries/chain/db_maint.cpp index 15a72afe..5ffef31a 100644 --- a/libraries/chain/db_maint.cpp +++ b/libraries/chain/db_maint.cpp @@ -828,6 +828,24 @@ share_type credit_account(database& db, const account_id_type owner_id, const st return remaining_amount_to_distribute; } +void rolling_period_start(database& db) +{ + if(db.head_block_time() >= HARDFORK_GPOS_TIME) + { + auto period_start = db.get_global_properties().parameters.period_start; + auto vesting_period = db.get_global_properties().parameters.vesting_period; + + auto now = db.head_block_time().sec_since_epoch(); + if(now > (period_start + vesting_period)) + { + // roll + db.modify(db.get_global_properties(), [now](global_property_object& p) { + p.parameters.period_start = now; + }); + } + } +} + // Schedules payouts from a dividend distribution account to the current holders of the // dividend-paying asset. This takes any deposits made to the dividend distribution account // since the last time it was called, and distributes them to the current owners of the @@ -1377,6 +1395,8 @@ void database::perform_chain_maintenance(const signed_block& next_block, const g process_dividend_assets(*this); + rolling_period_start(*this); + struct vote_tally_helper { database& d; const global_property_object& props;