mirror of
https://github.com/mimblewimble/grin.git
synced 2025-02-01 17:01:09 +03:00
cleanup mine_block difficulty_iterator usage (#1674)
* take care with diff_iter (contains an active lmdb batch) * rustfmt
This commit is contained in:
parent
c86578c2a9
commit
60ef7268ba
2 changed files with 4 additions and 6 deletions
|
@ -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<Result<(u64, Difficulty), consensus::TargetError>> =
|
||||
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)
|
||||
|
|
|
@ -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...
|
||||
|
|
Loading…
Reference in a new issue