Added getter for witness schedule object
This commit is contained in:
parent
04102d549c
commit
dcc6902720
5 changed files with 16 additions and 18 deletions
|
|
@ -149,5 +149,9 @@ const account_statistics_object& database::get_account_stats_by_owner( account_i
|
|||
return *itr;
|
||||
}
|
||||
|
||||
const witness_schedule_object& database::get_witness_schedule_object()const
|
||||
{
|
||||
return *_p_witness_schedule_obj;
|
||||
}
|
||||
|
||||
} }
|
||||
|
|
|
|||
|
|
@ -921,7 +921,7 @@ void database::init_genesis(const genesis_state_type& genesis_state)
|
|||
});
|
||||
|
||||
// Set active witnesses
|
||||
modify(get_global_properties(), [&](global_property_object& p) {
|
||||
modify(get_global_properties(), [&genesis_state](global_property_object& p) {
|
||||
for( uint32_t i = 1; i <= genesis_state.initial_active_witnesses; ++i )
|
||||
{
|
||||
p.active_witnesses.insert(witness_id_type(i));
|
||||
|
|
@ -929,10 +929,7 @@ void database::init_genesis(const genesis_state_type& genesis_state)
|
|||
});
|
||||
|
||||
// Initialize witness schedule
|
||||
#ifndef NDEBUG
|
||||
const witness_schedule_object& wso =
|
||||
#endif
|
||||
create<witness_schedule_object>([&](witness_schedule_object& _wso)
|
||||
_p_witness_schedule_obj = & create<witness_schedule_object>([this](witness_schedule_object& _wso)
|
||||
{
|
||||
// for scheduled
|
||||
memset(_wso.rng_seed.begin(), 0, _wso.rng_seed.size());
|
||||
|
|
@ -956,19 +953,13 @@ void database::init_genesis(const genesis_state_type& genesis_state)
|
|||
for( const witness_id_type& wid : get_global_properties().active_witnesses )
|
||||
_wso.current_shuffled_witnesses.push_back( wid );
|
||||
});
|
||||
assert( wso.id == witness_schedule_id_type() );
|
||||
FC_ASSERT( _p_witness_schedule_obj->id == witness_schedule_id_type() );
|
||||
|
||||
// Enable fees
|
||||
modify(get_global_properties(), [&genesis_state](global_property_object& p) {
|
||||
p.parameters.current_fees = genesis_state.initial_parameters.current_fees;
|
||||
});
|
||||
|
||||
// Create witness scheduler
|
||||
//create<witness_schedule_object>([&]( witness_schedule_object& wso )
|
||||
//{
|
||||
// for( const witness_id_type& wid : get_global_properties().active_witnesses )
|
||||
// wso.current_shuffled_witnesses.push_back( wid );
|
||||
//});
|
||||
|
||||
// Create FBA counters
|
||||
create<fba_accumulator_object>([&]( fba_accumulator_object& acc )
|
||||
|
|
|
|||
|
|
@ -220,6 +220,7 @@ void database::open(
|
|||
_p_global_prop_obj = &get( global_property_id_type() );
|
||||
_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() );
|
||||
}
|
||||
|
||||
fc::optional<block_id_type> last_block = _block_id_to_block.last_id();
|
||||
|
|
|
|||
|
|
@ -38,14 +38,14 @@ witness_id_type database::get_scheduled_witness( uint32_t slot_num )const
|
|||
if (gpo.parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SHUFFLED_ALGORITHM)
|
||||
{
|
||||
const dynamic_global_property_object& dpo = get_dynamic_global_properties();
|
||||
const witness_schedule_object& wso = witness_schedule_id_type()(*this);
|
||||
const witness_schedule_object& wso = get_witness_schedule_object();;
|
||||
uint64_t current_aslot = dpo.current_aslot + slot_num;
|
||||
return wso.current_shuffled_witnesses[ current_aslot % wso.current_shuffled_witnesses.size() ];
|
||||
}
|
||||
if (gpo.parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SCHEDULED_ALGORITHM &&
|
||||
slot_num != 0 )
|
||||
{
|
||||
const witness_schedule_object& wso = witness_schedule_id_type()(*this);
|
||||
const witness_schedule_object& wso = get_witness_schedule_object();;
|
||||
// ask the near scheduler who goes in the given slot
|
||||
bool slot_is_near = wso.scheduler.get_slot(slot_num-1, wid);
|
||||
if(! slot_is_near)
|
||||
|
|
@ -113,7 +113,7 @@ uint32_t database::get_slot_at_time(fc::time_point_sec when)const
|
|||
|
||||
void database::update_witness_schedule()
|
||||
{
|
||||
const witness_schedule_object& wso = witness_schedule_id_type()(*this);
|
||||
const witness_schedule_object& wso = get_witness_schedule_object();
|
||||
const global_property_object& gpo = get_global_properties();
|
||||
|
||||
if( head_block_num() % gpo.active_witnesses.size() == 0 )
|
||||
|
|
@ -148,7 +148,7 @@ void database::update_witness_schedule()
|
|||
|
||||
vector<witness_id_type> database::get_near_witness_schedule()const
|
||||
{
|
||||
const witness_schedule_object& wso = witness_schedule_id_type()(*this);
|
||||
const witness_schedule_object& wso = get_witness_schedule_object();
|
||||
|
||||
vector<witness_id_type> result;
|
||||
result.reserve(wso.scheduler.size());
|
||||
|
|
@ -165,7 +165,7 @@ void database::update_witness_schedule(const signed_block& next_block)
|
|||
{
|
||||
auto start = fc::time_point::now();
|
||||
const global_property_object& gpo = get_global_properties();
|
||||
const witness_schedule_object& wso = get(witness_schedule_id_type());
|
||||
const witness_schedule_object& wso = get_witness_schedule_object();
|
||||
uint32_t schedule_needs_filled = gpo.active_witnesses.size();
|
||||
uint32_t schedule_slot = get_slot_at_time(next_block.timestamp);
|
||||
|
||||
|
|
@ -252,7 +252,7 @@ uint32_t database::witness_participation_rate()const
|
|||
}
|
||||
if (gpo.parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SCHEDULED_ALGORITHM)
|
||||
{
|
||||
const witness_schedule_object& wso = get(witness_schedule_id_type());
|
||||
const witness_schedule_object& wso = get_witness_schedule_object();
|
||||
return uint64_t(GRAPHENE_100_PERCENT) * wso.recent_slots_filled.popcount() / 128;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -280,6 +280,7 @@ namespace graphene { namespace chain {
|
|||
const std::vector<uint32_t> get_winner_numbers( asset_id_type for_asset, uint32_t count_members, uint8_t count_winners ) const;
|
||||
std::vector<uint32_t> get_seeds( asset_id_type for_asset, uint8_t count_winners )const;
|
||||
uint64_t get_random_bits( uint64_t bound );
|
||||
const witness_schedule_object& get_witness_schedule_object()const;
|
||||
|
||||
time_point_sec head_block_time()const;
|
||||
uint32_t head_block_num()const;
|
||||
|
|
@ -595,6 +596,7 @@ namespace graphene { namespace chain {
|
|||
const global_property_object* _p_global_prop_obj = nullptr;
|
||||
const dynamic_global_property_object* _p_dyn_global_prop_obj = nullptr;
|
||||
const chain_property_object* _p_chain_property_obj = nullptr;
|
||||
const witness_schedule_object* _p_witness_schedule_obj = nullptr;
|
||||
///@}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue