Skip to content

Commit

Permalink
getblocks retry only on 'Block not found on disk'
Browse files Browse the repository at this point in the history
  • Loading branch information
RCasatta committed Sep 25, 2024
1 parent 272c868 commit 26ed614
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/new_index/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 26ed614

Please sign in to comment.