Skip to content

Commit 8f97b56

Browse files
author
Ludo Galabru
committed
fix: early return
1 parent 5441851 commit 8f97b56

File tree

2 files changed

+37
-6
lines changed

2 files changed

+37
-6
lines changed

components/chainhook-cli/src/scan/bitcoin.rs

+23-4
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,20 @@ pub async fn scan_bitcoin_chain_with_predicate(
169169
let block_hash = retrieve_block_hash_with_retry(&cursor, &bitcoin_config, ctx).await?;
170170
let block_breakdown =
171171
download_and_parse_block_with_retry(&block_hash, &bitcoin_config, ctx).await?;
172-
let mut block = indexer::bitcoin::standardize_bitcoin_block(
172+
let mut block = match indexer::bitcoin::standardize_bitcoin_block(
173173
block_breakdown,
174174
&event_observer_config.bitcoin_network,
175175
ctx,
176-
)?;
176+
) {
177+
Ok(data) => data,
178+
Err(e) => {
179+
warn!(
180+
ctx.expect_logger(),
181+
"Unable to standardize block#{} {}: {}", cursor, block_hash, e
182+
);
183+
continue;
184+
}
185+
};
177186

178187
update_storage_and_augment_bitcoin_block_with_inscription_reveal_data(
179188
&mut block,
@@ -215,11 +224,21 @@ pub async fn scan_bitcoin_chain_with_predicate(
215224
let block_hash = retrieve_block_hash_with_retry(&cursor, &bitcoin_config, ctx).await?;
216225
let block_breakdown =
217226
download_and_parse_block_with_retry(&block_hash, &bitcoin_config, ctx).await?;
218-
let block = indexer::bitcoin::standardize_bitcoin_block(
227+
228+
let block = match indexer::bitcoin::standardize_bitcoin_block(
219229
block_breakdown,
220230
&event_observer_config.bitcoin_network,
221231
ctx,
222-
)?;
232+
) {
233+
Ok(data) => data,
234+
Err(e) => {
235+
warn!(
236+
ctx.expect_logger(),
237+
"Unable to standardize block#{} {}: {}", cursor, block_hash, e
238+
);
239+
continue;
240+
}
241+
};
223242

224243
let chain_event =
225244
BitcoinChainEvent::ChainUpdatedWithBlocks(BitcoinChainUpdatedWithBlocksData {

components/chainhook-cli/src/service/mod.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -465,11 +465,23 @@ impl Service {
465465
.result::<indexer::bitcoin::BitcoinBlockFullBreakdown>()
466466
.map_err(|e| format!("unable to parse response ({})", e))?;
467467

468-
let block = indexer::bitcoin::standardize_bitcoin_block(
468+
let block = match indexer::bitcoin::standardize_bitcoin_block(
469469
raw_block,
470470
&event_observer_config.bitcoin_network,
471471
&self.ctx,
472-
)?;
472+
) {
473+
Ok(data) => data,
474+
Err(e) => {
475+
warn!(
476+
self.ctx.expect_logger(),
477+
"Unable to standardize block#{} {}: {}",
478+
cursor,
479+
block_hash,
480+
e
481+
);
482+
continue;
483+
}
484+
};
473485

474486
let mut hits = vec![];
475487
for tx in block.transactions.iter() {

0 commit comments

Comments
 (0)