#550 - update schedule for sidechain type
This commit is contained in:
parent
f23244cde0
commit
3a51723e51
4 changed files with 72 additions and 96 deletions
|
|
@ -29,8 +29,6 @@ build-mainnet:
|
|||
- build/libraries/
|
||||
- build/programs/
|
||||
- build/tests/
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "beatrice" || $CI_COMMIT_BRANCH == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "beatrice" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop"
|
||||
tags:
|
||||
- builder
|
||||
|
||||
|
|
@ -81,8 +79,6 @@ build-testnet:
|
|||
- build/libraries/
|
||||
- build/programs/
|
||||
- build/tests/
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "beatrice" || $CI_COMMIT_BRANCH == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "beatrice" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop"
|
||||
when: manual
|
||||
tags:
|
||||
- builder
|
||||
|
|
|
|||
|
|
@ -739,13 +739,11 @@ void database::_apply_block( const signed_block& next_block )
|
|||
|
||||
if (global_props.parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SCHEDULED_ALGORITHM) {
|
||||
update_witness_schedule(next_block);
|
||||
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(!active_sons.second.empty()) {
|
||||
update_son_schedule(active_sons.first, next_block);
|
||||
}
|
||||
if(need_to_update_son_schedule) {
|
||||
update_son_schedule(next_block);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -783,15 +781,11 @@ void database::_apply_block( const signed_block& next_block )
|
|||
if (global_props.parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SHUFFLED_ALGORITHM) {
|
||||
update_witness_schedule();
|
||||
|
||||
bool need_update_son_schedule = false;
|
||||
for(const auto& active_sidechain_type : active_sidechain_types(dynamic_global_props.time)) {
|
||||
if(global_props.active_sons.at(active_sidechain_type).size() > 0) {
|
||||
need_update_son_schedule = true;
|
||||
update_son_schedule(active_sidechain_type);
|
||||
}
|
||||
}
|
||||
if(need_update_son_schedule) {
|
||||
update_son_schedule();
|
||||
}
|
||||
}
|
||||
|
||||
if( !_node_property_object.debug_updates.empty() )
|
||||
|
|
|
|||
|
|
@ -200,22 +200,20 @@ void database::update_witness_schedule()
|
|||
}
|
||||
}
|
||||
|
||||
void database::update_son_schedule()
|
||||
void database::update_son_schedule(sidechain_type type)
|
||||
{
|
||||
const global_property_object& gpo = get_global_properties();
|
||||
|
||||
for(const auto& active_sidechain_type : active_sidechain_types(head_block_time()))
|
||||
{
|
||||
const son_schedule_object& sidechain_sso = get(son_schedule_id_type(get_son_schedule_id(active_sidechain_type)));
|
||||
if( gpo.active_sons.at(active_sidechain_type).size() != 0 &&
|
||||
head_block_num() % gpo.active_sons.at(active_sidechain_type).size() == 0)
|
||||
const son_schedule_object& sidechain_sso = get(son_schedule_id_type(get_son_schedule_id(type)));
|
||||
if( gpo.active_sons.at(type).size() != 0 &&
|
||||
head_block_num() % gpo.active_sons.at(type).size() == 0)
|
||||
{
|
||||
modify( sidechain_sso, [&]( son_schedule_object& _sso )
|
||||
{
|
||||
_sso.current_shuffled_sons.clear();
|
||||
_sso.current_shuffled_sons.reserve( gpo.active_sons.at(active_sidechain_type).size() );
|
||||
_sso.current_shuffled_sons.reserve( gpo.active_sons.at(type).size() );
|
||||
|
||||
for ( const auto &w : gpo.active_sons.at(active_sidechain_type) ) {
|
||||
for ( const auto &w : gpo.active_sons.at(type) ) {
|
||||
_sso.current_shuffled_sons.push_back(w.son_id);
|
||||
}
|
||||
|
||||
|
|
@ -239,7 +237,6 @@ void database::update_son_schedule()
|
|||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vector<witness_id_type> database::get_near_witness_schedule()const
|
||||
{
|
||||
|
|
@ -321,23 +318,15 @@ void database::update_witness_schedule(const signed_block& next_block)
|
|||
idump( ( double(total_time/1000000.0)/calls) );
|
||||
}
|
||||
|
||||
void database::update_son_schedule(const signed_block& next_block)
|
||||
void database::update_son_schedule(sidechain_type type, const signed_block& next_block)
|
||||
{
|
||||
auto start = fc::time_point::now();
|
||||
#ifndef NDEBUG
|
||||
const son_schedule_object& sso = get(son_schedule_id_type());
|
||||
#endif
|
||||
const global_property_object& gpo = get_global_properties();
|
||||
const flat_map<sidechain_type, uint32_t> schedule_needs_filled = [&gpo]()
|
||||
{
|
||||
flat_map<sidechain_type, uint32_t> schedule_needs_filled;
|
||||
for(const auto& sidechain_active_sons : gpo.active_sons)
|
||||
{
|
||||
schedule_needs_filled[sidechain_active_sons.first] = sidechain_active_sons.second.size();
|
||||
}
|
||||
return schedule_needs_filled;
|
||||
}();
|
||||
uint32_t schedule_slot = get_slot_at_time(next_block.timestamp);
|
||||
const uint32_t schedule_needs_filled = gpo.active_sons.at(type).size();
|
||||
const uint32_t schedule_slot = get_slot_at_time(next_block.timestamp);
|
||||
|
||||
// We shouldn't be able to generate _pending_block with timestamp
|
||||
// in the past, and incoming blocks from the network with timestamp
|
||||
|
|
@ -351,9 +340,7 @@ void database::update_son_schedule(const signed_block& next_block)
|
|||
assert( dpo.random.data_size() == witness_scheduler_rng::seed_length );
|
||||
assert( witness_scheduler_rng::seed_length == sso.rng_seed.size() );
|
||||
|
||||
for(const auto& active_sidechain_type : active_sidechain_types(head_block_time()))
|
||||
{
|
||||
const son_schedule_object& sidechain_sso = get(son_schedule_id_type(get_son_schedule_id(active_sidechain_type)));
|
||||
const son_schedule_object& sidechain_sso = get(son_schedule_id_type(get_son_schedule_id(type)));
|
||||
son_id_type first_son;
|
||||
bool slot_is_near = sidechain_sso.scheduler.get_slot( schedule_slot-1, first_son );
|
||||
son_id_type son_id;
|
||||
|
|
@ -363,7 +350,7 @@ void database::update_son_schedule(const signed_block& next_block)
|
|||
_sso.slots_since_genesis += schedule_slot;
|
||||
witness_scheduler_rng rng(_sso.rng_seed.data, _sso.slots_since_genesis);
|
||||
|
||||
_sso.scheduler._min_token_count = std::max(int(gpo.active_sons.at(active_sidechain_type).size()) / 2, 1);
|
||||
_sso.scheduler._min_token_count = std::max(int(gpo.active_sons.at(type).size()) / 2, 1);
|
||||
|
||||
if( slot_is_near )
|
||||
{
|
||||
|
|
@ -380,7 +367,7 @@ void database::update_son_schedule(const signed_block& next_block)
|
|||
{
|
||||
_sso.scheduler.reset_schedule( first_son );
|
||||
}
|
||||
while( !_sso.scheduler.get_slot(schedule_needs_filled.at(active_sidechain_type), son_id) )
|
||||
while( !_sso.scheduler.get_slot(schedule_needs_filled, son_id) )
|
||||
{
|
||||
if( _sso.scheduler.produce_schedule(rng) & emit_turn )
|
||||
memcpy(_sso.rng_seed.begin(), dpo.random.data(), dpo.random.data_size());
|
||||
|
|
@ -390,7 +377,6 @@ void database::update_son_schedule(const signed_block& next_block)
|
|||
(_sso.recent_slots_filled << 1)
|
||||
+ 1) << (schedule_slot - 1);
|
||||
});
|
||||
}
|
||||
|
||||
auto end = fc::time_point::now();
|
||||
static uint64_t total_time = 0;
|
||||
|
|
|
|||
|
|
@ -292,8 +292,8 @@ namespace graphene { namespace chain {
|
|||
vector<witness_id_type> get_near_witness_schedule()const;
|
||||
void update_witness_schedule();
|
||||
void update_witness_schedule(const signed_block& next_block);
|
||||
void update_son_schedule();
|
||||
void update_son_schedule(const signed_block& next_block);
|
||||
void update_son_schedule(sidechain_type type);
|
||||
void update_son_schedule(sidechain_type type, const signed_block& next_block);
|
||||
|
||||
void check_lottery_end_by_participants( asset_id_type asset_id );
|
||||
void check_ending_lotteries();
|
||||
|
|
|
|||
Loading…
Reference in a new issue