-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: adjust difficulty in the mining loop
closes #154 When the timestamp is adjusted in the mining loop it is necessary to also adjust the difficulty and difficulty threshhold. This was not happening before, which led to: 1. occasional difficulty validation errors 2. mean time-to-find-block that does not match expected mean. This commit also adds a target_block_interval param to the mining loop function, which enables tests to perform simulated mining at much higher speeds, eg 1 second per block. Changes: block/mod.rs: * Block::set_header_timestamp() --> Block::set_header_timestamp_and_difficulty() * log actual and expected valuus if difficulty validation fails * add test difficulty_control_matches() mine_loop.rs: * adjust difficulty and threshold in mining loop with the timestamp * mining_loop fn accepts a target_block_interval * improve test mine_ten_blocks_in_ten_seconds()
- Loading branch information
Showing
2 changed files
with
116 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters