From: emma31-dev Date: Fri, 13 Nov 2026 12:05:07 +0000 (+0100) Subject: refactor(full_scan): share the stop-gap rejection check X-Git-Url: http://internal-gitweb-vhost/-script/src/consensus/example_cli/struct.EncoderStringWriter.html?a=commitdiff_plain;h=12aae534965a678d7419e13dab8a235a3b751641;p=bdk-cli refactor(full_scan): share the stop-gap rejection check The RPC and CBF arms carried an identical `--scan-stop-gap` rejection block, each with its own `electrum`/`esplora` cfg. Move the check into a `reject_stop_gap` helper next to `stop_gap` so there is one copy of the message and one gate. No behaviour change. --- diff --git a/src/handlers/online.rs b/src/handlers/online.rs index 0b7342b..d28d9ed 100644 --- a/src/handlers/online.rs +++ b/src/handlers/online.rs @@ -121,6 +121,21 @@ impl FullScanCommand { } } +#[cfg(any(feature = "rpc", feature = "cbf"))] +impl FullScanCommand { + /// Rejects `--scan-stop-gap` for backends that do not use it: RPC walks blocks and CBF + /// follows the filter lookahead, so neither reads `stop_gap`. + fn reject_stop_gap(&self) -> Result<(), Error> { + #[cfg(any(feature = "electrum", feature = "esplora"))] + if self.stop_gap.is_some() { + return Err(Error::Generic( + "`--scan-stop-gap` is only supported by the electrum and esplora backends".into(), + )); + } + Ok(()) + } +} + #[cfg(any( feature = "electrum", feature = "esplora", @@ -173,13 +188,7 @@ impl AsyncAppCommand>> for FullScanCommand { } #[cfg(feature = "rpc")] RpcClient { client } => { - #[cfg(any(feature = "electrum", feature = "esplora"))] - if self.stop_gap.is_some() { - return Err(Error::Generic( - "`--scan-stop-gap` is only supported by the electrum and esplora backends" - .into(), - )); - } + self.reject_stop_gap()?; let blockchain_info = client.get_blockchain_info()?; @@ -228,13 +237,7 @@ impl AsyncAppCommand>> for FullScanCommand { #[cfg(feature = "cbf")] KyotoClient { client } => { - #[cfg(any(feature = "electrum", feature = "esplora"))] - if self.stop_gap.is_some() { - return Err(Error::Generic( - "`--scan-stop-gap` is only supported by the electrum and esplora backends" - .into(), - )); - } + self.reject_stop_gap()?; sync_kyoto_client(wallet, client).await?; }