Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle target difficulty conversion failure #5710

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions base_layer/core/src/consensus/consensus_manager.rs
Original file line number Diff line number Diff line change
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
Loading