diff --git a/servers/src/grin/server.rs b/servers/src/grin/server.rs index f67226e32..0935340e8 100644 --- a/servers/src/grin/server.rs +++ b/servers/src/grin/server.rs @@ -395,10 +395,8 @@ impl Server { // code clean. This may be handy for testing but not really needed // for release let diff_stats = { - let diff_iter = self.chain.difficulty_iter(); - let last_blocks: Vec> = - global::difficulty_data_to_vector(diff_iter) + global::difficulty_data_to_vector(self.chain.difficulty_iter()) .into_iter() .skip(consensus::MEDIAN_TIME_WINDOW as usize) .take(consensus::DIFFICULTY_ADJUST_WINDOW as usize) diff --git a/servers/src/mining/mine_block.rs b/servers/src/mining/mine_block.rs index d0ba3e696..f1862bdb3 100644 --- a/servers/src/mining/mine_block.rs +++ b/servers/src/mining/mine_block.rs @@ -104,9 +104,9 @@ fn build_block( now_sec = head_sec + 1; } - // get the difficulty our block should be at - let diff_iter = chain.difficulty_iter(); - let difficulty = consensus::next_difficulty(diff_iter).unwrap(); + // Determine the difficulty our block should be at. + // Note: do not keep the difficulty_iter in scope (it has an active batch). + let difficulty = consensus::next_difficulty(chain.difficulty_iter()).unwrap(); // extract current transaction from the pool // TODO - we have a lot of unwrap() going on in this fn...