witness: Submit wakeup time for fc::schedule() on local system clock, not NTP
This commit is contained in:
parent
a1b00b2749
commit
fda84dfe8b
1 changed files with 11 additions and 5 deletions
|
|
@ -146,12 +146,18 @@ void witness_plugin::plugin_shutdown()
|
|||
void witness_plugin::schedule_production_loop()
|
||||
{
|
||||
//Schedule for the next second's tick regardless of chain state
|
||||
// If we would wait less than 200ms, wait for the whole second.
|
||||
fc::time_point now = graphene::time::now();
|
||||
fc::time_point_sec next_second( now + fc::microseconds( 1200000 ) );
|
||||
//wdump( (now.time_since_epoch().count())(next_second) );
|
||||
// If we would wait less than 50ms, wait for the whole second.
|
||||
fc::time_point ntp_now = graphene::time::now();
|
||||
fc::time_point fc_now = fc::time_point::now();
|
||||
int64_t time_to_next_second = 1000000 - (ntp_now.time_since_epoch().count() % 1000000);
|
||||
if( time_to_next_second < 50000 ) // we must sleep for at least 50ms
|
||||
time_to_next_second += 1000000;
|
||||
|
||||
fc::time_point next_wakeup( fc_now + fc::microseconds( time_to_next_second ) );
|
||||
|
||||
//wdump( (now.time_since_epoch().count())(next_wakeup.time_since_epoch().count()) );
|
||||
_block_production_task = fc::schedule([this]{block_production_loop();},
|
||||
next_second, "Witness Block Production");
|
||||
next_wakeup, "Witness Block Production");
|
||||
}
|
||||
|
||||
block_production_condition::block_production_condition_enum witness_plugin::block_production_loop()
|
||||
|
|
|
|||
Loading…
Reference in a new issue