Skip to content

Commit

Permalink
fix: handle target difficulty conversion failure (tari-project#5710)
Browse files Browse the repository at this point in the history
Description
---
Maps the error to the expected result.

Motivation and Context
---
Just to handle conversion failure mo' betta.

How Has This Been Tested?
---
CI

Breaking Changes
---

- [x] None
- [ ] Requires data directory on base node to be deleted
- [ ] Requires hard fork
- [ ] Other - Please specify
  • Loading branch information
brianp committed Sep 1, 2023
1 parent 8d84bf5 commit 431c35a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions base_layer/core/src/consensus/consensus_manager.rs
Expand Up @@ -124,10 +124,10 @@ impl ConsensusManager {
let constants = self.consensus_constants(height);
let block_window = constants.difficulty_block_window();

TargetDifficultyWindow::new(
usize::try_from(block_window).expect("difficulty block window exceeds usize::MAX"),
constants.pow_target_block_interval(pow_algo),
)
let block_window_u = usize::try_from(block_window)
.map_err(|e| format!("difficulty block window exceeds usize::MAX: {}", e.to_string()))?;

TargetDifficultyWindow::new(block_window_u, constants.pow_target_block_interval(pow_algo))
}

/// Creates a total_coinbase offset containing all fees for the validation from the height and kernel set
Expand Down

0 comments on commit 431c35a

Please sign in to comment.