From: Matt Corallo <649246+TheBlueMatt@users.noreply.github.com> Date: Thu, 1 Feb 2024 17:39:10 +0000 (+0000) Subject: Merge pull request #72 from lightningdevkit/arik/2024/01/bitcoin-rest-error X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=9c8d2791678cebe9ec08bc776999a3c0a5562477;hp=e98acc1a90b78d9d426e0f5bdaf0e94318971c2f;p=rapid-gossip-sync-server Merge pull request #72 from lightningdevkit/arik/2024/01/bitcoin-rest-error Improve bitcoind RPC/Rest error message --- diff --git a/src/verifier.rs b/src/verifier.rs index 5e91244..3d58ee0 100644 --- a/src/verifier.rs +++ b/src/verifier.rs @@ -1,4 +1,5 @@ use std::convert::TryInto; +use std::io::ErrorKind; use std::ops::Deref; use std::sync::Arc; use std::sync::Mutex; @@ -65,7 +66,15 @@ impl ChainVerifier where L::Target: let block_hash_result = client.request_resource::(&uri).await; let block_hash: Vec = block_hash_result.map_err(|error| { - log_error!(logger, "Could't find block hash at height {}: {}", block_height, error.to_string()); + match error.kind() { + ErrorKind::InvalidData => { + // the response length was likely 0 + log_error!(logger, "Could't find block hash at height {}: Invalid response! Please make sure the `-rest=1` flag is set.", block_height); + } + _ => { + log_error!(logger, "Could't find block hash at height {}: {}", block_height, error.to_string()); + } + } UtxoLookupError::UnknownChain })?.0; let block_hash = BlockHash::from_slice(&block_hash).unwrap();