fix: increment sortition processing!

This commit is contained in:
Aaron Blankstein
2023-04-06 11:07:28 -05:00
committed by Brice Dobry
parent e2c1923745
commit 4236b84252

View File

@@ -38,6 +38,7 @@ use crate::{BurnchainController, Config, EventDispatcher};
use super::RunLoopCallbacks;
use libc;
pub const STDERR: i32 = 2;
pub const SORTITION_PROCESS_INCREMENTS: u64 = 1000;
#[cfg(test)]
pub type RunLoopCounter = Arc<AtomicU64>;
@@ -537,13 +538,9 @@ impl RunLoop {
let mut burnchain_height = sortition_db_height;
let mut num_sortitions_in_last_cycle = 1;
// prepare to fetch the first reward cycle!
let mut target_burnchain_block_height = burnchain_config.reward_cycle_to_block_height(
burnchain_config
.block_height_to_reward_cycle(burnchain_height)
.expect("BUG: block height is not in a reward cycle")
+ 1,
);
// prepare to fetch the first set of sortitions
let mut target_burnchain_block_height =
(1 + (burnchain_height / SORTITION_PROCESS_INCREMENTS)) * SORTITION_PROCESS_INCREMENTS;
debug!(
"Begin main runloop starting a burnchain block {}",
@@ -684,6 +681,8 @@ impl RunLoop {
}
}
target_burnchain_block_height += SORTITION_PROCESS_INCREMENTS;
if sortition_db_height >= burnchain_height && !ibd {
let canonical_stacks_tip_height =
SortitionDB::get_canonical_burn_chain_tip(burnchain.sortdb_ref().conn())