Browse files

base speculation staleness on time

Previously, we based the stale speculation check on the `_production_enabled` flag which is set, at most, once per process.  This lead to a situation where a node which fell behind would still speculate.  This changes that check to be based on the age of the head block so, nodes which fall behind will stop speculating.  NOTE, this only affects speculative modes, actual production should attempt to proceed despite the age of the head block.

relates to #4649
  • Loading branch information...
wanderingbort committed Jul 17, 2018
1 parent 8644de7 commit 397659bd55532c943f21aa9d1df3f5f573ad70c4
Showing with 4 additions and 2 deletions.
  1. +4 −2 plugins/producer_plugin/producer_plugin.cpp
@@ -876,8 +876,10 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block(bool
if (_pending_block_mode == pending_block_mode::speculating && !_production_enabled) {
return start_block_result::waiting;
if (_pending_block_mode == pending_block_mode::speculating) {
auto head_block_age = now - chain.head_block_time();
if (head_block_age > fc::seconds(5))
return start_block_result::waiting;
try {

0 comments on commit 397659b

Please sign in to comment.