@@ -7,7 +7,7 @@ use crate::db::{
7
7
delete_data_in_hord_db, find_all_inscription_transfers, find_all_inscriptions_in_block,
8
8
find_all_transfers_in_block, find_inscription_with_id, find_last_block_inserted,
9
9
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,
11
11
open_readonly_hord_db_conn, open_readonly_hord_db_conn_rocks_db, open_readwrite_hord_db_conn,
12
12
open_readwrite_hord_db_conn_rocks_db, rebuild_rocks_db,
13
13
remove_entries_from_locations_at_block_height, retrieve_satoshi_point_using_lazy_storage,
@@ -23,13 +23,14 @@ use chainhook_sdk::chainhooks::types::{
23
23
ChainhookFullSpecification , HookAction , OrdinalOperations ,
24
24
} ;
25
25
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,
27
27
} ;
28
28
use chainhook_sdk:: observer:: BitcoinConfig ;
29
29
use chainhook_sdk:: types:: { BitcoinBlockData , BlockIdentifier , TransactionIdentifier } ;
30
30
use chainhook_sdk:: utils:: Context ;
31
31
use clap:: { Parser , Subcommand } ;
32
32
use hiro_system_kit;
33
+ use reqwest:: Client as HttpClient ;
33
34
use std:: collections:: BTreeMap ;
34
35
use std:: io:: { BufReader , Read } ;
35
36
use std:: path:: PathBuf ;
@@ -654,9 +655,14 @@ async fn handle_command(opts: Opts, ctx: &Context) -> Result<(), String> {
654
655
let event_observer_config = config. get_event_observer_config ( ) ;
655
656
let hord_config = config. get_hord_config ( ) ;
656
657
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 ?;
660
666
let traversals_cache = Arc :: new ( new_traversals_lazy_cache ( 1024 ) ) ;
661
667
662
668
let _traversals = retrieve_inscribed_satoshi_points_from_block (
@@ -782,12 +788,18 @@ async fn handle_command(opts: Opts, ctx: &Context) -> Result<(), String> {
782
788
} ;
783
789
let ( tx, rx) = channel ( ) ;
784
790
let moved_ctx = ctx. clone ( ) ;
791
+ let http_client = build_http_client ( ) ;
792
+
785
793
hiro_system_kit:: thread_named ( "Block fetch" )
786
794
. spawn ( move || {
787
795
for cursor in cmd. start_block ..=cmd. end_block {
788
796
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
+ ) ;
791
803
792
804
let block = hiro_system_kit:: nestable_block_on ( future) . unwrap ( ) ;
793
805
@@ -901,13 +913,16 @@ pub fn load_predicate_from_path(
901
913
}
902
914
903
915
pub async fn fetch_and_standardize_block (
916
+ http_client : & HttpClient ,
904
917
block_height : u64 ,
905
918
bitcoin_config : & BitcoinConfig ,
906
919
ctx : & Context ,
907
920
) -> 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 ?;
909
923
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 ?;
911
926
912
927
hord:: parse_ordinals_and_standardize_block ( block_breakdown, & bitcoin_config. network , & ctx)
913
928
. map_err ( |( e, _) | e)
0 commit comments