Skip to content

Commit

Permalink
GH-1432 Also restart speculative blocks every block interval when con…
Browse files Browse the repository at this point in the history
…figured with producers
  • Loading branch information
heifner committed Aug 14, 2023
1 parent fffbbf3 commit bf02319
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions plugins/producer_plugin/producer_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1889,6 +1889,8 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block() {
last_start_block_time = now;
}

// create speculative blocks at regular intervals, so we create blocks with "current" block time
_pending_block_deadline = now + fc::microseconds(config::block_interval_us);
if (in_producing_mode()) {
uint32_t production_round_index = block_timestamp_type(block_time).slot % chain::config::producer_repetitions;
if (production_round_index == 0) {
Expand All @@ -1907,10 +1909,8 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block() {
auto wake_time = block_timing_util::calculate_producer_wake_up_time(config::block_interval_us, chain.head_block_num(), chain.head_block_time(),
_producers, chain.head_block_state()->active_schedule.producers,
_producer_watermarks);
_pending_block_deadline = wake_time ? *wake_time : now + fc::microseconds(config::block_interval_us);
} else {
// set a deadline for the next block time, so we consistently create blocks with "current" block time
_pending_block_deadline = now + fc::microseconds(config::block_interval_us);
if (wake_time)
_pending_block_deadline = std::min(*wake_time, _pending_block_deadline);
}

const auto& preprocess_deadline = _pending_block_deadline;
Expand Down

0 comments on commit bf02319

Please sign in to comment.