@@ -8,7 +8,7 @@ use std::{
8
8
use chainhook_postgres:: { pg_begin, pg_pool_client} ;
9
9
use chainhook_sdk:: utils:: Context ;
10
10
use chainhook_types:: { BitcoinBlockData , TransactionIdentifier } ;
11
- use crossbeam_channel:: { Sender , TryRecvError } ;
11
+ use crossbeam_channel:: TryRecvError ;
12
12
13
13
use dashmap:: DashMap ;
14
14
use fxhash:: FxHasher ;
@@ -33,11 +33,7 @@ use crate::{
33
33
sequence_cursor:: SequenceCursor ,
34
34
} ,
35
35
} ,
36
- db:: {
37
- blocks:: { self , open_blocks_db_with_retry} ,
38
- cursor:: TransactionBytesCursor ,
39
- ordinals_pg,
40
- } ,
36
+ db:: { blocks:: open_blocks_db_with_retry, cursor:: TransactionBytesCursor , ordinals_pg} ,
41
37
service:: PgConnectionPools ,
42
38
try_crit, try_debug, try_info,
43
39
utils:: monitoring:: PrometheusMonitoring ,
@@ -55,7 +51,6 @@ pub fn start_inscription_indexing_processor(
55
51
config : & Config ,
56
52
pg_pools : & PgConnectionPools ,
57
53
ctx : & Context ,
58
- post_processor : Option < Sender < BitcoinBlockData > > ,
59
54
prometheus : & PrometheusMonitoring ,
60
55
) -> PostProcessorController {
61
56
let ( commands_tx, commands_rx) = crossbeam_channel:: bounded :: < PostProcessorCommand > ( 2 ) ;
@@ -122,7 +117,6 @@ pub fn start_inscription_indexing_processor(
122
117
& mut sequence_cursor,
123
118
& cache_l2,
124
119
& mut brc20_cache,
125
- & post_processor,
126
120
& prometheus,
127
121
& config,
128
122
& pg_pools,
@@ -155,12 +149,11 @@ pub fn start_inscription_indexing_processor(
155
149
}
156
150
}
157
151
158
- pub async fn process_blocks (
152
+ async fn process_blocks (
159
153
next_blocks : & mut Vec < BitcoinBlockData > ,
160
154
sequence_cursor : & mut SequenceCursor ,
161
155
cache_l2 : & Arc < DashMap < ( u32 , [ u8 ; 8 ] ) , TransactionBytesCursor , BuildHasherDefault < FxHasher > > > ,
162
156
brc20_cache : & mut Option < Brc20MemoryCache > ,
163
- post_processor : & Option < Sender < BitcoinBlockData > > ,
164
157
prometheus : & PrometheusMonitoring ,
165
158
config : & Config ,
166
159
pg_pools : & PgConnectionPools ,
@@ -172,14 +165,7 @@ pub async fn process_blocks(
172
165
for _cursor in 0 ..next_blocks. len ( ) {
173
166
let mut block = next_blocks. remove ( 0 ) ;
174
167
175
- // Invalidate and recompute cursor when crossing the jubilee height
176
- let jubilee_height =
177
- get_jubilee_block_height ( & get_bitcoin_network ( & block. metadata . network ) ) ;
178
- if block. block_identifier . index == jubilee_height {
179
- sequence_cursor. reset ( ) ;
180
- }
181
-
182
- process_block (
168
+ index_block (
183
169
& mut block,
184
170
& next_blocks,
185
171
sequence_cursor,
@@ -193,15 +179,12 @@ pub async fn process_blocks(
193
179
)
194
180
. await ?;
195
181
196
- if let Some ( post_processor_tx) = post_processor {
197
- let _ = post_processor_tx. send ( block. clone ( ) ) ;
198
- }
199
182
updated_blocks. push ( block) ;
200
183
}
201
184
Ok ( updated_blocks)
202
185
}
203
186
204
- pub async fn process_block (
187
+ pub async fn index_block (
205
188
block : & mut BitcoinBlockData ,
206
189
next_blocks : & Vec < BitcoinBlockData > ,
207
190
sequence_cursor : & mut SequenceCursor ,
@@ -217,6 +200,13 @@ pub async fn process_block(
217
200
let block_height = block. block_identifier . index ;
218
201
try_info ! ( ctx, "Indexing block #{block_height}" ) ;
219
202
203
+ // Invalidate and recompute cursor when crossing the jubilee height
204
+ if block. block_identifier . index
205
+ == get_jubilee_block_height ( & get_bitcoin_network ( & block. metadata . network ) )
206
+ {
207
+ sequence_cursor. reset ( ) ;
208
+ }
209
+
220
210
{
221
211
let mut ord_client = pg_pool_client ( & pg_pools. ordinals ) . await ?;
222
212
let ord_tx = pg_begin ( & mut ord_client) . await ?;
@@ -233,16 +223,11 @@ pub async fn process_block(
233
223
config,
234
224
ctx,
235
225
) ?;
236
- let inner_ctx = if config. logs . ordinals_internals {
237
- ctx. clone ( )
238
- } else {
239
- Context :: empty ( )
240
- } ;
241
226
if has_inscription_reveals {
242
- augment_block_with_inscriptions ( block, sequence_cursor, cache_l1, & ord_tx, & inner_ctx )
227
+ augment_block_with_inscriptions ( block, sequence_cursor, cache_l1, & ord_tx, ctx )
243
228
. await ?;
244
229
}
245
- augment_block_with_transfers ( block, & ord_tx, & inner_ctx ) . await ?;
230
+ augment_block_with_transfers ( block, & ord_tx, ctx ) . await ?;
246
231
247
232
// Write data
248
233
ordinals_pg:: insert_block ( block, & ord_tx) . await ?;
@@ -294,15 +279,6 @@ pub async fn rollback_block(
294
279
ctx : & Context ,
295
280
) -> Result < ( ) , String > {
296
281
try_info ! ( ctx, "Rolling back block #{block_height}" ) ;
297
- // Drop from blocks DB.
298
- let blocks_db = open_blocks_db_with_retry ( true , & config, ctx) ;
299
- blocks:: delete_blocks_in_block_range (
300
- block_height as u32 ,
301
- block_height as u32 ,
302
- & blocks_db,
303
- & ctx,
304
- ) ;
305
- // Drop from postgres.
306
282
{
307
283
let mut ord_client = pg_pool_client ( & pg_pools. ordinals ) . await ?;
308
284
let ord_tx = pg_begin ( & mut ord_client) . await ?;
0 commit comments