Skip to content

Commit

Permalink
Use correct height and depth in reorg log (#2352)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmart7t2 authored Aug 22, 2023
1 parent 47d2aff commit 8a95a0f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ impl Index {
log::info!("{}", err.to_string());

match err.downcast_ref() {
Some(&ReorgError::Recoverable((height, depth))) => {
Some(&ReorgError::Recoverable { height, depth }) => {
Reorg::handle_reorg(self, height, depth)?;

updater = Updater::new(self)?;
Expand Down
6 changes: 3 additions & 3 deletions src/index/reorg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ use {super::*, updater::BlockData};

#[derive(Debug, PartialEq)]
pub(crate) enum ReorgError {
Recoverable((u64, u64)),
Recoverable { height: u64, depth: u64 },
Unrecoverable,
}

impl fmt::Display for ReorgError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
ReorgError::Recoverable((height, depth)) => {
ReorgError::Recoverable { height, depth } => {
write!(f, "{depth} block deep reorg detected at height {height}")
}
ReorgError::Unrecoverable => write!(f, "unrecoverable reorg detected"),
Expand Down Expand Up @@ -43,7 +43,7 @@ impl Reorg {
.into_option()?;

if index_block_hash == bitcoind_block_hash {
return Err(anyhow!(ReorgError::Recoverable((depth, height))));
return Err(anyhow!(ReorgError::Recoverable { height, depth }));
}
}

Expand Down

0 comments on commit 8a95a0f

Please sign in to comment.