@@ -39,11 +39,12 @@ use crate::{
39
39
OrdhookConfig ,
40
40
} ,
41
41
db:: {
42
- get_any_entry_in_ordinal_activities, open_ordhook_db_conn_rocks_db_loop ,
43
- open_readonly_ordhook_db_conn,
42
+ get_any_entry_in_ordinal_activities, get_latest_indexed_inscription_number ,
43
+ open_ordhook_db_conn_rocks_db_loop , open_readonly_ordhook_db_conn,
44
44
} ,
45
45
service:: write_brc20_block_operations,
46
46
try_error, try_info,
47
+ utils:: monitoring:: PrometheusMonitoring ,
47
48
} ;
48
49
49
50
use crate :: db:: { TransactionBytesCursor , TraversalResult } ;
@@ -61,12 +62,14 @@ pub fn start_inscription_indexing_processor(
61
62
config : & Config ,
62
63
ctx : & Context ,
63
64
post_processor : Option < Sender < BitcoinBlockData > > ,
65
+ prometheus : & PrometheusMonitoring ,
64
66
) -> PostProcessorController {
65
67
let ( commands_tx, commands_rx) = crossbeam_channel:: bounded :: < PostProcessorCommand > ( 2 ) ;
66
68
let ( events_tx, events_rx) = crossbeam_channel:: unbounded :: < PostProcessorEvent > ( ) ;
67
69
68
70
let config = config. clone ( ) ;
69
71
let ctx = ctx. clone ( ) ;
72
+ let prometheus = prometheus. clone ( ) ;
70
73
let handle: JoinHandle < ( ) > = hiro_system_kit:: thread_named ( "Inscription indexing runloop" )
71
74
. spawn ( move || {
72
75
let cache_l2 = Arc :: new ( new_traversals_lazy_cache ( 2048 ) ) ;
@@ -143,6 +146,7 @@ pub fn start_inscription_indexing_processor(
143
146
& mut brc20_db_conn_rw,
144
147
& ordhook_config,
145
148
& post_processor,
149
+ & prometheus,
146
150
& ctx,
147
151
) ;
148
152
@@ -181,6 +185,7 @@ pub fn process_blocks(
181
185
brc20_db_conn_rw : & mut Option < Connection > ,
182
186
ordhook_config : & OrdhookConfig ,
183
187
post_processor : & Option < Sender < BitcoinBlockData > > ,
188
+ prometheus : & PrometheusMonitoring ,
184
189
ctx : & Context ,
185
190
) -> Vec < BitcoinBlockData > {
186
191
let mut cache_l1 = BTreeMap :: new ( ) ;
@@ -216,6 +221,7 @@ pub fn process_blocks(
216
221
& inscriptions_db_tx,
217
222
brc20_db_tx. as_ref ( ) ,
218
223
brc20_cache. as_mut ( ) ,
224
+ prometheus,
219
225
ordhook_config,
220
226
ctx,
221
227
) ;
@@ -284,6 +290,7 @@ pub fn process_block(
284
290
inscriptions_db_tx : & Transaction ,
285
291
brc20_db_tx : Option < & Transaction > ,
286
292
brc20_cache : Option < & mut Brc20MemoryCache > ,
293
+ prometheus : & PrometheusMonitoring ,
287
294
ordhook_config : & OrdhookConfig ,
288
295
ctx : & Context ,
289
296
) -> Result < ( ) , String > {
@@ -307,7 +314,7 @@ pub fn process_block(
307
314
Context :: empty ( )
308
315
} ;
309
316
310
- // Handle inscriptions
317
+ // Inscriptions
311
318
if any_processable_transactions {
312
319
let _ = augment_block_with_ordinals_inscriptions_data_and_write_to_db_tx (
313
320
block,
@@ -317,10 +324,9 @@ pub fn process_block(
317
324
& inner_ctx,
318
325
) ;
319
326
}
320
-
321
- // Handle transfers
327
+ // Transfers
322
328
let _ = augment_block_with_ordinals_transfer_data ( block, inscriptions_db_tx, true , & inner_ctx) ;
323
-
329
+ // BRC-20
324
330
match ( brc20_db_tx, brc20_cache) {
325
331
( Some ( brc20_db_tx) , Some ( brc20_cache) ) => write_brc20_block_operations (
326
332
block,
@@ -332,5 +338,11 @@ pub fn process_block(
332
338
_ => { }
333
339
}
334
340
341
+ // Monitoring
342
+ prometheus. metrics_block_indexed ( block. block_identifier . index ) ;
343
+ prometheus. metrics_inscription_indexed (
344
+ get_latest_indexed_inscription_number ( inscriptions_db_tx, & inner_ctx) . unwrap_or ( 0 ) ,
345
+ ) ;
346
+
335
347
Ok ( ( ) )
336
348
}
0 commit comments