From 26ed614986331a80a7ef6f0fd162c83cd144fdb4 Mon Sep 17 00:00:00 2001 From: Riccardo Casatta Date: Wed, 25 Sep 2024 19:49:49 +0200 Subject: [PATCH] getblocks retry only on 'Block not found on disk' --- src/new_index/fetch.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/new_index/fetch.rs b/src/new_index/fetch.rs index f0516045a..a5ecf4d4c 100644 --- a/src/new_index/fetch.rs +++ b/src/new_index/fetch.rs @@ -7,6 +7,7 @@ use bitcoin::consensus::encode::{deserialize, Decodable}; #[cfg(feature = "liquid")] use elements::encode::{deserialize, Decodable}; +use core::panic; use std::collections::HashMap; use std::fs; use std::io::Cursor; @@ -90,8 +91,15 @@ fn bitcoind_fetcher( match daemon.getblocks(&blockhashes) { Ok(blocks) => break blocks, Err(e) => { - // There is a small chance the node returns the header but didn't finish to index the block - log::warn!("getblocks failing with: {e:?} trying {attempts} more time") + let err_msg = format!("{e:?}"); + if err_msg.contains("Block not found on disk") { + // There is a small chance the node returns the header but didn't finish to index the block + log::warn!( + "getblocks failing with: {e:?} trying {attempts} more time" + ) + } else { + panic!("failed to get blocks from bitcoind: {}", err_msg); + } } } if attempts == 0 {