Skip to content

Commit

Permalink
Merge remote-tracking branch 'spring/release/1.0-beta4' into GH-436-p…
Browse files Browse the repository at this point in the history
…rod-change-main
  • Loading branch information
heifner committed Aug 5, 2024
2 parents e0f2d5d + e651ebb commit 18320e3
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions plugins/producer_plugin/producer_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1880,6 +1880,17 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block() {
_pending_block_mode = pending_block_mode::speculating;
}

if (in_speculating_mode()) {
static fc::time_point last_start_block_time = fc::time_point::maximum(); // always start with speculative block
// Determine if we are syncing: if we have recently started an old block then assume we are syncing
if (last_start_block_time < now + fc::microseconds(config::block_interval_us)) {
auto head_block_age = now - chain.head().block_time();
if (head_block_age > fc::seconds(5))
return start_block_result::waiting_for_block; // if syncing no need to create a block just to immediately abort it
}
last_start_block_time = now;
}

if (in_producing_mode()) {
// determine if our watermark excludes us from producing at this point
if (auto current_watermark = _producer_watermarks.get_watermark(scheduled_producer.producer_name)) {
Expand All @@ -1898,17 +1909,6 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block() {
}
}

if (in_speculating_mode()) {
static fc::time_point last_start_block_time = fc::time_point::maximum(); // always start with speculative block
// Determine if we are syncing: if we have recently started an old block then assume we are syncing
if (last_start_block_time < now + fc::microseconds(config::block_interval_us)) {
auto head_block_age = now - chain.head().block_time();
if (head_block_age > fc::seconds(5))
return start_block_result::waiting_for_block; // if syncing no need to create a block just to immediately abort it
}
last_start_block_time = now;
}

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 Down

0 comments on commit 18320e3

Please sign in to comment.