#308 - fix global_property_object active_sons initialization

This commit is contained in:
Vlad Dobromyslov 2022-04-04 08:36:13 +03:00
parent f6c9b1b7a6
commit e217fb94f3
3 changed files with 21 additions and 8 deletions

View file

@ -700,7 +700,12 @@ void database::_apply_block( const signed_block& next_block )
if (global_props.parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SCHEDULED_ALGORITHM) { if (global_props.parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SCHEDULED_ALGORITHM) {
update_witness_schedule(next_block); update_witness_schedule(next_block);
if(global_props.active_sons.size() > 0) { bool need_to_update_son_schedule = false;
for(const auto& active_sons : global_props.active_sons){
if(!active_sons.second.empty())
need_to_update_son_schedule = true;
}
if(need_to_update_son_schedule) {
update_son_schedule(next_block); update_son_schedule(next_block);
} }
} }

View file

@ -874,10 +874,10 @@ void database::update_active_sons()
}); });
_sso.scheduler.update(active_sons); _sso.scheduler.update(active_sons);
// similar to witness, produce schedule for sons // similar to witness, produce schedule for sons
if(cur_active_sons.size() == 0 && new_active_sons.size() > 0) if(cur_active_sons.at(sidechain_type::bitcoin).size() == 0 && new_active_sons.at(sidechain_type::bitcoin).size() > 0)
{ {
witness_scheduler_rng rng(_sso.rng_seed.begin(), GRAPHENE_NEAR_SCHEDULE_CTR_IV); witness_scheduler_rng rng(_sso.rng_seed.begin(), GRAPHENE_NEAR_SCHEDULE_CTR_IV);
for( size_t i=0; i<new_active_sons.size(); ++i ) for( size_t i=0; i<new_active_sons.at(sidechain_type::bitcoin).size(); ++i )
_sso.scheduler.produce_schedule(rng); _sso.scheduler.produce_schedule(rng);
} }
}); });
@ -897,10 +897,10 @@ void database::update_active_sons()
}); });
_sso.scheduler.update(active_sons); _sso.scheduler.update(active_sons);
// similar to witness, produce schedule for sons // similar to witness, produce schedule for sons
if(cur_active_sons.size() == 0 && new_active_sons.size() > 0) if(cur_active_sons.at(sidechain_type::hive).size() == 0 && new_active_sons.at(sidechain_type::hive).size() > 0)
{ {
witness_scheduler_rng rng(_sso.rng_seed.begin(), GRAPHENE_NEAR_SCHEDULE_CTR_IV); witness_scheduler_rng rng(_sso.rng_seed.begin(), GRAPHENE_NEAR_SCHEDULE_CTR_IV);
for( size_t i=0; i<new_active_sons.size(); ++i ) for( size_t i=0; i<new_active_sons.at(sidechain_type::hive).size(); ++i )
_sso.scheduler.produce_schedule(rng); _sso.scheduler.produce_schedule(rng);
} }
}); });
@ -920,10 +920,10 @@ void database::update_active_sons()
}); });
_sso.scheduler.update(active_sons); _sso.scheduler.update(active_sons);
// similar to witness, produce schedule for sons // similar to witness, produce schedule for sons
if(cur_active_sons.size() == 0 && new_active_sons.size() > 0) if(cur_active_sons.at(sidechain_type::bitcoin).size() == 0 && new_active_sons.at(sidechain_type::bitcoin).size() > 0)
{ {
witness_scheduler_rng rng(_sso.rng_seed.begin(), GRAPHENE_NEAR_SCHEDULE_CTR_IV); witness_scheduler_rng rng(_sso.rng_seed.begin(), GRAPHENE_NEAR_SCHEDULE_CTR_IV);
for( size_t i=0; i<new_active_sons.size(); ++i ) for( size_t i=0; i<new_active_sons.at(sidechain_type::bitcoin).size(); ++i )
_sso.scheduler.produce_schedule(rng); _sso.scheduler.produce_schedule(rng);
} }
}); });

View file

@ -52,7 +52,15 @@ namespace graphene { namespace chain {
uint32_t next_available_vote_id = 0; uint32_t next_available_vote_id = 0;
vector<committee_member_id_type> active_committee_members; // updated once per maintenance interval vector<committee_member_id_type> active_committee_members; // updated once per maintenance interval
flat_set<witness_id_type> active_witnesses; // updated once per maintenance interval flat_set<witness_id_type> active_witnesses; // updated once per maintenance interval
flat_map<sidechain_type, vector<son_info> > active_sons; // updated once per maintenance interval
//! Fixme - delete sidechain type from here
flat_map<sidechain_type, vector<son_info> > active_sons = []() // updated once per maintenance interval
{
flat_map<sidechain_type, vector<son_info> > active_sons;
active_sons[sidechain_type::bitcoin] = vector<son_info>();
active_sons[sidechain_type::hive] = vector<son_info>();
return active_sons;
}();
// n.b. witness scheduling is done by witness_schedule object // n.b. witness scheduling is done by witness_schedule object
}; };