@@ -5,9 +5,14 @@ use chainhook_event_observer::chainhooks::bitcoin::{
5
5
handle_bitcoin_hook_action, BitcoinChainhookOccurrence , BitcoinTriggerChainhook ,
6
6
} ;
7
7
use chainhook_event_observer:: chainhooks:: types:: BitcoinChainhookFullSpecification ;
8
- use chainhook_event_observer:: indexer;
8
+ use chainhook_event_observer:: indexer:: ordinals:: indexing:: updater:: OrdinalIndexUpdater ;
9
+ use chainhook_event_observer:: indexer:: ordinals:: initialize_ordinal_index;
10
+ use chainhook_event_observer:: indexer:: { self , BitcoinChainContext } ;
11
+ use chainhook_event_observer:: observer:: {
12
+ EventObserverConfig , DEFAULT_CONTROL_PORT , DEFAULT_INGESTION_PORT ,
13
+ } ;
9
14
use chainhook_event_observer:: utils:: { file_append, send_request, Context } ;
10
- use std:: collections:: HashMap ;
15
+ use std:: collections:: { HashMap , HashSet } ;
11
16
use std:: time:: Duration ;
12
17
13
18
pub async fn scan_bitcoin_chain_with_predicate (
@@ -133,8 +138,40 @@ pub async fn scan_bitcoin_chain_with_predicate(
133
138
. result :: < indexer:: bitcoin:: Block > ( )
134
139
. map_err ( |e| format ! ( "unable to parse response ({})" , e) ) ?;
135
140
136
- let block =
137
- indexer:: bitcoin:: standardize_bitcoin_block ( & config. network , cursor, raw_block, ctx) ?;
141
+ let event_observer_config = EventObserverConfig {
142
+ normalization_enabled : true ,
143
+ grpc_server_enabled : false ,
144
+ hooks_enabled : true ,
145
+ bitcoin_rpc_proxy_enabled : true ,
146
+ event_handlers : vec ! [ ] ,
147
+ chainhook_config : None ,
148
+ ingestion_port : DEFAULT_INGESTION_PORT ,
149
+ control_port : DEFAULT_CONTROL_PORT ,
150
+ bitcoin_node_username : config. network . bitcoin_node_rpc_username . clone ( ) ,
151
+ bitcoin_node_password : config. network . bitcoin_node_rpc_password . clone ( ) ,
152
+ bitcoin_node_rpc_url : config. network . bitcoin_node_rpc_url . clone ( ) ,
153
+ stacks_node_rpc_url : config. network . stacks_node_rpc_url . clone ( ) ,
154
+ operators : HashSet :: new ( ) ,
155
+ display_logs : false ,
156
+ cache_path : config. storage . cache_path . clone ( ) ,
157
+ bitcoin_network : config. network . bitcoin_network . clone ( ) ,
158
+ } ;
159
+
160
+ let ordinal_index = initialize_ordinal_index ( & event_observer_config) . unwrap ( ) ;
161
+ match OrdinalIndexUpdater :: update ( & ordinal_index) {
162
+ Ok ( _r) => { }
163
+ Err ( e) => { }
164
+ }
165
+
166
+ let mut bitcoin_context = BitcoinChainContext :: new ( ordinal_index) ;
167
+
168
+ let block = indexer:: bitcoin:: standardize_bitcoin_block (
169
+ & config. network ,
170
+ cursor,
171
+ raw_block,
172
+ & mut bitcoin_context,
173
+ ctx,
174
+ ) ?;
138
175
139
176
let mut hits = vec ! [ ] ;
140
177
for tx in block. transactions . iter ( ) {
0 commit comments