Skip to content

Commit

Permalink
fix: early return
Browse files Browse the repository at this point in the history
  • Loading branch information
lgalabru committed Apr 12, 2023
1 parent 5441851 commit 8f97b56
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
27 changes: 23 additions & 4 deletions components/chainhook-cli/src/scan/bitcoin.rs
Expand Up @@ -169,11 +169,20 @@ pub async fn scan_bitcoin_chain_with_predicate(
let block_hash = retrieve_block_hash_with_retry(&cursor, &bitcoin_config, ctx).await?;
let block_breakdown =
download_and_parse_block_with_retry(&block_hash, &bitcoin_config, ctx).await?;
let mut block = indexer::bitcoin::standardize_bitcoin_block(
let mut block = match indexer::bitcoin::standardize_bitcoin_block(
block_breakdown,
&event_observer_config.bitcoin_network,
ctx,
)?;
) {
Ok(data) => data,
Err(e) => {
warn!(
ctx.expect_logger(),
"Unable to standardize block#{} {}: {}", cursor, block_hash, e
);
continue;
}
};

update_storage_and_augment_bitcoin_block_with_inscription_reveal_data(
&mut block,
Expand Down Expand Up @@ -215,11 +224,21 @@ pub async fn scan_bitcoin_chain_with_predicate(
let block_hash = retrieve_block_hash_with_retry(&cursor, &bitcoin_config, ctx).await?;
let block_breakdown =
download_and_parse_block_with_retry(&block_hash, &bitcoin_config, ctx).await?;
let block = indexer::bitcoin::standardize_bitcoin_block(

let block = match indexer::bitcoin::standardize_bitcoin_block(
block_breakdown,
&event_observer_config.bitcoin_network,
ctx,
)?;
) {
Ok(data) => data,
Err(e) => {
warn!(
ctx.expect_logger(),
"Unable to standardize block#{} {}: {}", cursor, block_hash, e
);
continue;
}
};

let chain_event =
BitcoinChainEvent::ChainUpdatedWithBlocks(BitcoinChainUpdatedWithBlocksData {
Expand Down
16 changes: 14 additions & 2 deletions components/chainhook-cli/src/service/mod.rs
Expand Up @@ -465,11 +465,23 @@ impl Service {
.result::<indexer::bitcoin::BitcoinBlockFullBreakdown>()
.map_err(|e| format!("unable to parse response ({})", e))?;

let block = indexer::bitcoin::standardize_bitcoin_block(
let block = match indexer::bitcoin::standardize_bitcoin_block(
raw_block,
&event_observer_config.bitcoin_network,
&self.ctx,
)?;
) {
Ok(data) => data,
Err(e) => {
warn!(
self.ctx.expect_logger(),
"Unable to standardize block#{} {}: {}",
cursor,
block_hash,
e
);
continue;
}
};

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

0 comments on commit 8f97b56

Please sign in to comment.