mirror of
https://github.com/mimblewimble/grin.git
synced 2025-02-08 12:21: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
|
// code clean. This may be handy for testing but not really needed
|
||||||
// for release
|
// for release
|
||||||
let diff_stats = {
|
let diff_stats = {
|
||||||
let diff_iter = self.chain.difficulty_iter();
|
|
||||||
|
|
||||||
let last_blocks: Vec<Result<(u64, Difficulty), consensus::TargetError>> =
|
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()
|
.into_iter()
|
||||||
.skip(consensus::MEDIAN_TIME_WINDOW as usize)
|
.skip(consensus::MEDIAN_TIME_WINDOW as usize)
|
||||||
.take(consensus::DIFFICULTY_ADJUST_WINDOW as usize)
|
.take(consensus::DIFFICULTY_ADJUST_WINDOW as usize)
|
||||||
|
|
|
@ -104,9 +104,9 @@ fn build_block(
|
||||||
now_sec = head_sec + 1;
|
now_sec = head_sec + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the difficulty our block should be at
|
// Determine the difficulty our block should be at.
|
||||||
let diff_iter = chain.difficulty_iter();
|
// Note: do not keep the difficulty_iter in scope (it has an active batch).
|
||||||
let difficulty = consensus::next_difficulty(diff_iter).unwrap();
|
let difficulty = consensus::next_difficulty(chain.difficulty_iter()).unwrap();
|
||||||
|
|
||||||
// extract current transaction from the pool
|
// extract current transaction from the pool
|
||||||
// TODO - we have a lot of unwrap() going on in this fn...
|
// TODO - we have a lot of unwrap() going on in this fn...
|
||||||
|
|
Loading…
Reference in a new issue