shuffled witnesses repaired
This commit is contained in:
parent
90ec694446
commit
a8244963e7
3 changed files with 14 additions and 15 deletions
|
|
@ -789,6 +789,7 @@ void database::init_genesis(const genesis_state_type& genesis_state)
|
||||||
#endif
|
#endif
|
||||||
create<witness_schedule_object>([&](witness_schedule_object& _wso)
|
create<witness_schedule_object>([&](witness_schedule_object& _wso)
|
||||||
{
|
{
|
||||||
|
// for scheduled
|
||||||
memset(_wso.rng_seed.begin(), 0, _wso.rng_seed.size());
|
memset(_wso.rng_seed.begin(), 0, _wso.rng_seed.size());
|
||||||
|
|
||||||
witness_scheduler_rng rng(_wso.rng_seed.begin(), GRAPHENE_NEAR_SCHEDULE_CTR_IV);
|
witness_scheduler_rng rng(_wso.rng_seed.begin(), GRAPHENE_NEAR_SCHEDULE_CTR_IV);
|
||||||
|
|
@ -805,6 +806,10 @@ void database::init_genesis(const genesis_state_type& genesis_state)
|
||||||
_wso.last_scheduling_block = 0;
|
_wso.last_scheduling_block = 0;
|
||||||
|
|
||||||
_wso.recent_slots_filled = fc::uint128::max_value();
|
_wso.recent_slots_filled = fc::uint128::max_value();
|
||||||
|
|
||||||
|
// for shuffled
|
||||||
|
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() );
|
assert( wso.id == witness_schedule_id_type() );
|
||||||
|
|
||||||
|
|
@ -814,11 +819,11 @@ void database::init_genesis(const genesis_state_type& genesis_state)
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create witness scheduler
|
// Create witness scheduler
|
||||||
create<witness_schedule_object>([&]( witness_schedule_object& wso )
|
//create<witness_schedule_object>([&]( witness_schedule_object& wso )
|
||||||
{
|
//{
|
||||||
for( const witness_id_type& wid : get_global_properties().active_witnesses )
|
// for( const witness_id_type& wid : get_global_properties().active_witnesses )
|
||||||
wso.current_shuffled_witnesses.push_back( wid );
|
// wso.current_shuffled_witnesses.push_back( wid );
|
||||||
});
|
//});
|
||||||
|
|
||||||
// Create FBA counters
|
// Create FBA counters
|
||||||
create<fba_accumulator_object>([&]( fba_accumulator_object& acc )
|
create<fba_accumulator_object>([&]( fba_accumulator_object& acc )
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,9 @@ fc::time_point_sec database::get_slot_time(uint32_t slot_num)const
|
||||||
uint32_t database::get_slot_at_time(fc::time_point_sec when)const
|
uint32_t database::get_slot_at_time(fc::time_point_sec when)const
|
||||||
{
|
{
|
||||||
fc::time_point_sec first_slot_time = get_slot_time( 1 );
|
fc::time_point_sec first_slot_time = get_slot_time( 1 );
|
||||||
std::cout << "romek " << when.to_iso_string() << " " << first_slot_time.to_iso_string() << "\n";
|
#ifndef NDEBUG
|
||||||
|
std::cout << "@get_slot_at_time " << when.to_iso_string() << " " << first_slot_time.to_iso_string() << "\n";
|
||||||
|
#endif
|
||||||
if( when < first_slot_time )
|
if( when < first_slot_time )
|
||||||
return 0;
|
return 0;
|
||||||
return (when - first_slot_time).to_seconds() / block_interval() + 1;
|
return (when - first_slot_time).to_seconds() / block_interval() + 1;
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ namespace graphene { namespace chain {
|
||||||
|
|
||||||
class witness_schedule_object;
|
class witness_schedule_object;
|
||||||
|
|
||||||
//#ifndef GRAPHENE_SHUFFLED_WITNESSES
|
|
||||||
typedef hash_ctr_rng<
|
typedef hash_ctr_rng<
|
||||||
/* HashClass = */ fc::sha256,
|
/* HashClass = */ fc::sha256,
|
||||||
/* SeedLength = */ GRAPHENE_RNG_SEED_LENGTH
|
/* SeedLength = */ GRAPHENE_RNG_SEED_LENGTH
|
||||||
|
|
@ -53,7 +52,6 @@ typedef generic_far_future_witness_scheduler<
|
||||||
/* OffsetType = */ uint32_t,
|
/* OffsetType = */ uint32_t,
|
||||||
/* debug = */ true
|
/* debug = */ true
|
||||||
> far_future_witness_scheduler;
|
> far_future_witness_scheduler;
|
||||||
//#endif
|
|
||||||
|
|
||||||
class witness_schedule_object : public graphene::db::abstract_object<witness_schedule_object>
|
class witness_schedule_object : public graphene::db::abstract_object<witness_schedule_object>
|
||||||
{
|
{
|
||||||
|
|
@ -61,9 +59,8 @@ class witness_schedule_object : public graphene::db::abstract_object<witness_sch
|
||||||
static const uint8_t space_id = implementation_ids;
|
static const uint8_t space_id = implementation_ids;
|
||||||
static const uint8_t type_id = impl_witness_schedule_object_type;
|
static const uint8_t type_id = impl_witness_schedule_object_type;
|
||||||
|
|
||||||
//#ifdef GRAPHENE_SHUFFLED_WITNESSES
|
|
||||||
vector< witness_id_type > current_shuffled_witnesses;
|
vector< witness_id_type > current_shuffled_witnesses;
|
||||||
//#else
|
|
||||||
witness_scheduler scheduler;
|
witness_scheduler scheduler;
|
||||||
uint32_t last_scheduling_block;
|
uint32_t last_scheduling_block;
|
||||||
uint64_t slots_since_genesis = 0;
|
uint64_t slots_since_genesis = 0;
|
||||||
|
|
@ -74,14 +71,11 @@ class witness_schedule_object : public graphene::db::abstract_object<witness_sch
|
||||||
* The nth bit is 0 if the nth slot was unfilled, else it is 1.
|
* The nth bit is 0 if the nth slot was unfilled, else it is 1.
|
||||||
*/
|
*/
|
||||||
fc::uint128 recent_slots_filled;
|
fc::uint128 recent_slots_filled;
|
||||||
//#endif
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} }
|
} }
|
||||||
|
|
||||||
|
|
||||||
//#ifdef GRAPHENE_SHUFFLED_WITNESSES
|
|
||||||
FC_REFLECT( graphene::chain::witness_scheduler,
|
FC_REFLECT( graphene::chain::witness_scheduler,
|
||||||
(_turns)
|
(_turns)
|
||||||
(_tokens)
|
(_tokens)
|
||||||
|
|
@ -92,8 +86,6 @@ FC_REFLECT( graphene::chain::witness_scheduler,
|
||||||
(_schedule)
|
(_schedule)
|
||||||
(_lame_duck)
|
(_lame_duck)
|
||||||
)
|
)
|
||||||
|
|
||||||
//#ifdef GRAPHENE_SHUFFLED_WITNESSES
|
|
||||||
FC_REFLECT_DERIVED(
|
FC_REFLECT_DERIVED(
|
||||||
graphene::chain::witness_schedule_object,
|
graphene::chain::witness_schedule_object,
|
||||||
(graphene::db::object),
|
(graphene::db::object),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue