Skip to content

Commit 60cd4d0

Browse files
author
Ludo Galabru
committed
fix: build errors
1 parent f052e08 commit 60cd4d0

File tree

3 files changed

+33
-12
lines changed

3 files changed

+33
-12
lines changed

components/hord-cli/src/cli/mod.rs

+24-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::db::{
77
delete_data_in_hord_db, find_all_inscription_transfers, find_all_inscriptions_in_block,
88
find_all_transfers_in_block, find_inscription_with_id, find_last_block_inserted,
99
find_latest_inscription_block_height, find_lazy_block_at_block_height,
10-
find_watched_satpoint_for_inscription, initialize_hord_db, insert_entry_in_locations,
10+
initialize_hord_db, insert_entry_in_locations,
1111
open_readonly_hord_db_conn, open_readonly_hord_db_conn_rocks_db, open_readwrite_hord_db_conn,
1212
open_readwrite_hord_db_conn_rocks_db, rebuild_rocks_db,
1313
remove_entries_from_locations_at_block_height, retrieve_satoshi_point_using_lazy_storage,
@@ -23,13 +23,14 @@ use chainhook_sdk::chainhooks::types::{
2323
ChainhookFullSpecification, HookAction, OrdinalOperations,
2424
};
2525
use chainhook_sdk::indexer::bitcoin::{
26-
download_and_parse_block_with_retry, retrieve_block_hash_with_retry,
26+
build_http_client, download_and_parse_block_with_retry, retrieve_block_hash_with_retry,
2727
};
2828
use chainhook_sdk::observer::BitcoinConfig;
2929
use chainhook_sdk::types::{BitcoinBlockData, BlockIdentifier, TransactionIdentifier};
3030
use chainhook_sdk::utils::Context;
3131
use clap::{Parser, Subcommand};
3232
use hiro_system_kit;
33+
use reqwest::Client as HttpClient;
3334
use std::collections::BTreeMap;
3435
use std::io::{BufReader, Read};
3536
use std::path::PathBuf;
@@ -654,9 +655,14 @@ async fn handle_command(opts: Opts, ctx: &Context) -> Result<(), String> {
654655
let event_observer_config = config.get_event_observer_config();
655656
let hord_config = config.get_hord_config();
656657
let bitcoin_config = event_observer_config.get_bitcoin_config();
657-
let block =
658-
fetch_and_standardize_block(cmd.block_height, &bitcoin_config, &ctx)
659-
.await?;
658+
let http_client: HttpClient = build_http_client();
659+
let block = fetch_and_standardize_block(
660+
&http_client,
661+
cmd.block_height,
662+
&bitcoin_config,
663+
&ctx,
664+
)
665+
.await?;
660666
let traversals_cache = Arc::new(new_traversals_lazy_cache(1024));
661667

662668
let _traversals = retrieve_inscribed_satoshi_points_from_block(
@@ -782,12 +788,18 @@ async fn handle_command(opts: Opts, ctx: &Context) -> Result<(), String> {
782788
};
783789
let (tx, rx) = channel();
784790
let moved_ctx = ctx.clone();
791+
let http_client = build_http_client();
792+
785793
hiro_system_kit::thread_named("Block fetch")
786794
.spawn(move || {
787795
for cursor in cmd.start_block..=cmd.end_block {
788796
println!("Fetching block {}", cursor);
789-
let future =
790-
fetch_and_standardize_block(cursor, &bitcoin_config, &moved_ctx);
797+
let future = fetch_and_standardize_block(
798+
&http_client,
799+
cursor,
800+
&bitcoin_config,
801+
&moved_ctx,
802+
);
791803

792804
let block = hiro_system_kit::nestable_block_on(future).unwrap();
793805

@@ -901,13 +913,16 @@ pub fn load_predicate_from_path(
901913
}
902914

903915
pub async fn fetch_and_standardize_block(
916+
http_client: &HttpClient,
904917
block_height: u64,
905918
bitcoin_config: &BitcoinConfig,
906919
ctx: &Context,
907920
) -> Result<BitcoinBlockData, String> {
908-
let block_hash = retrieve_block_hash_with_retry(&block_height, &bitcoin_config, &ctx).await?;
921+
let block_hash =
922+
retrieve_block_hash_with_retry(http_client, &block_height, &bitcoin_config, &ctx).await?;
909923
let block_breakdown =
910-
download_and_parse_block_with_retry(&block_hash, &bitcoin_config, &ctx).await?;
924+
download_and_parse_block_with_retry(http_client, &block_hash, &bitcoin_config, &ctx)
925+
.await?;
911926

912927
hord::parse_ordinals_and_standardize_block(block_breakdown, &bitcoin_config.network, &ctx)
913928
.map_err(|(e, _)| e)

components/hord-cli/src/db/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ use std::{
44
hash::BuildHasherDefault,
55
path::PathBuf,
66
sync::{mpsc::Sender, Arc},
7-
time::Duration,
87
};
98

109
use chainhook_sdk::{
1110
indexer::bitcoin::{
12-
build_http_client, download_block_with_retry, parse_downloaded_block,
11+
build_http_client, download_block_with_retry,
1312
retrieve_block_hash_with_retry,
1413
},
1514
types::{

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

+8-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use chainhook_sdk::chainhooks::types::{
2424
ChainhookSpecification,
2525
};
2626

27+
use chainhook_sdk::indexer::bitcoin::build_http_client;
2728
use chainhook_sdk::observer::{start_event_observer, BitcoinConfig, ObserverEvent};
2829
use chainhook_sdk::types::{
2930
BitcoinBlockData, BitcoinChainEvent, BitcoinNetwork, OrdinalInscriptionTransferData,
@@ -435,9 +436,15 @@ impl Service {
435436
let moved_ctx = self.ctx.clone();
436437
hiro_system_kit::thread_named("Block fetch")
437438
.spawn(move || {
439+
let http_client = build_http_client();
438440
for cursor in start_block..=end_block {
439441
info!(moved_ctx.expect_logger(), "Fetching block {}", cursor);
440-
let future = fetch_and_standardize_block(cursor, &bitcoin_config, &moved_ctx);
442+
let future = fetch_and_standardize_block(
443+
&http_client,
444+
cursor,
445+
&bitcoin_config,
446+
&moved_ctx,
447+
);
441448

442449
let block = hiro_system_kit::nestable_block_on(future).unwrap();
443450

0 commit comments

Comments
 (0)