Fix for scheduler wrong state

Update random from dynamic global property

until the chain head point to keep consistance

state of schedulers
This commit is contained in:
hirunda 2022-05-30 23:47:06 +02:00
parent 0b04faec83
commit 95b03d30c1

View file

@ -225,6 +225,21 @@ void database::open(
_p_chain_property_obj = &get( chain_property_id_type() );
_p_dyn_global_prop_obj = &get( dynamic_global_property_id_type() );
_p_witness_schedule_obj = &get( witness_schedule_id_type() );
// Update 'random' from dynamic global property object to the state
// before shutdown happened. Since scheduler seeds depands on the
// right state of random dynamic global property
for (uint32_t i = 1; i <= head_block_num(); i++) {
// dynamic global properties updating
modify(*_p_dyn_global_prop_obj, [this, i](dynamic_global_property_object &dgp) {
secret_hash_type::encoder enc;
fc::raw::pack(enc, dgp.random);
const auto &block = fetch_block_by_number(i);
fc::raw::pack(enc, block->previous_secret);
dgp.random = enc.result();
});
}
}
fc::optional<block_id_type> last_block = _block_id_to_block.last_id();