From d9c81c363132770eecf353c45f5a040069231406 Mon Sep 17 00:00:00 2001 From: Greg Martin Date: Tue, 22 Aug 2023 21:27:28 +0000 Subject: [PATCH 1/2] Fix order of height and depth --- src/index/reorg.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index/reorg.rs b/src/index/reorg.rs index a1cb3b79f1..cab7b2aab2 100644 --- a/src/index/reorg.rs +++ b/src/index/reorg.rs @@ -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)))); } } From abcfee2c42574442e89af752275551f7dbb700c7 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Tue, 22 Aug 2023 14:47:39 -0700 Subject: [PATCH 2/2] Use record struct --- src/index.rs | 2 +- src/index/reorg.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/index.rs b/src/index.rs index 018f43c7eb..75e3f0ace5 100644 --- a/src/index.rs +++ b/src/index.rs @@ -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)?; diff --git a/src/index/reorg.rs b/src/index/reorg.rs index cab7b2aab2..fc6164282c 100644 --- a/src/index/reorg.rs +++ b/src/index/reorg.rs @@ -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"), @@ -43,7 +43,7 @@ impl Reorg { .into_option()?; if index_block_hash == bitcoind_block_hash { - return Err(anyhow!(ReorgError::Recoverable((height, depth)))); + return Err(anyhow!(ReorgError::Recoverable { height, depth })); } }