@@ -50,7 +50,7 @@ pub struct OrdinalIndexUpdater {
50
50
}
51
51
52
52
impl OrdinalIndexUpdater {
53
- pub fn update ( index : & OrdinalIndex ) -> Result {
53
+ pub async fn update ( index : & OrdinalIndex ) -> Result {
54
54
let wtx = index. begin_write ( ) ?;
55
55
56
56
let height = wtx
@@ -80,10 +80,10 @@ impl OrdinalIndexUpdater {
80
80
outputs_traversed : 0 ,
81
81
} ;
82
82
83
- updater. update_index ( index, wtx)
83
+ updater. update_index ( index, wtx) . await
84
84
}
85
85
86
- fn update_index < ' index > (
86
+ async fn update_index < ' index > (
87
87
& mut self ,
88
88
index : & ' index OrdinalIndex ,
89
89
mut wtx : WriteTransaction < ' index > ,
@@ -109,7 +109,7 @@ impl OrdinalIndexUpdater {
109
109
& mut wtx,
110
110
block,
111
111
& mut value_cache,
112
- ) ?;
112
+ ) . await ?;
113
113
114
114
uncommitted += 1 ;
115
115
@@ -305,12 +305,12 @@ impl OrdinalIndexUpdater {
305
305
Ok ( ( outpoint_sender, value_receiver) )
306
306
}
307
307
308
- fn index_block (
308
+ async fn index_block (
309
309
& mut self ,
310
310
index : & OrdinalIndex ,
311
311
outpoint_sender : & mut Sender < OutPoint > ,
312
312
value_receiver : & mut Receiver < u64 > ,
313
- wtx : & mut WriteTransaction ,
313
+ wtx : & mut WriteTransaction < ' _ > ,
314
314
block : BlockData ,
315
315
value_cache : & mut HashMap < OutPoint , u64 > ,
316
316
) -> Result < ( ) > {
@@ -351,7 +351,7 @@ impl OrdinalIndexUpdater {
351
351
continue ;
352
352
}
353
353
// We don't know the value of this tx input. Send this outpoint to background thread to be fetched
354
- outpoint_sender. blocking_send ( prev_output) ?;
354
+ let _ = outpoint_sender. send ( prev_output) . await ?;
355
355
}
356
356
}
357
357
}
@@ -409,7 +409,7 @@ impl OrdinalIndexUpdater {
409
409
) ?;
410
410
411
411
for ( tx, txid) in block. txdata . iter ( ) . skip ( 1 ) . chain ( block. txdata . first ( ) ) {
412
- lost_sats += inscription_updater. index_transaction_inscriptions ( tx, * txid, None ) ?;
412
+ lost_sats += inscription_updater. index_transaction_inscriptions ( tx, * txid, None ) . await ?;
413
413
}
414
414
415
415
statistic_to_count. insert ( & Statistic :: LostSats . key ( ) , & lost_sats) ?;
@@ -427,68 +427,68 @@ impl OrdinalIndexUpdater {
427
427
Ok ( ( ) )
428
428
}
429
429
430
- fn index_transaction_sats (
431
- & mut self ,
432
- tx : & Transaction ,
433
- txid : Txid ,
434
- sat_to_satpoint : & mut Table < u64 , & SatPointValue > ,
435
- input_sat_ranges : & mut VecDeque < ( u64 , u64 ) > ,
436
- sat_ranges_written : & mut u64 ,
437
- outputs_traversed : & mut u64 ,
438
- inscription_updater : & mut InscriptionUpdater ,
439
- ) -> Result {
440
- inscription_updater. index_transaction_inscriptions ( tx, txid, Some ( input_sat_ranges) ) ?;
441
-
442
- for ( vout, output) in tx. output . iter ( ) . enumerate ( ) {
443
- let outpoint = OutPoint {
444
- vout : vout. try_into ( ) . unwrap ( ) ,
445
- txid,
446
- } ;
447
- let mut sats = Vec :: new ( ) ;
448
-
449
- let mut remaining = output. value ;
450
- while remaining > 0 {
451
- let range = input_sat_ranges. pop_front ( ) . ok_or_else ( || {
452
- anyhow:: anyhow!( "insufficient inputs for transaction outputs" )
453
- } ) ?;
454
-
455
- if !Sat ( range. 0 ) . is_common ( ) {
456
- sat_to_satpoint. insert (
457
- & range. 0 ,
458
- & SatPoint {
459
- outpoint,
460
- offset : output. value - remaining,
461
- }
462
- . store ( ) ,
463
- ) ?;
464
- }
465
-
466
- let count = range. 1 - range. 0 ;
467
-
468
- let assigned = if count > remaining {
469
- self . sat_ranges_since_flush += 1 ;
470
- let middle = range. 0 + remaining;
471
- input_sat_ranges. push_front ( ( middle, range. 1 ) ) ;
472
- ( range. 0 , middle)
473
- } else {
474
- range
475
- } ;
476
-
477
- sats. extend_from_slice ( & assigned. store ( ) ) ;
478
-
479
- remaining -= assigned. 1 - assigned. 0 ;
480
-
481
- * sat_ranges_written += 1 ;
482
- }
483
-
484
- * outputs_traversed += 1 ;
485
-
486
- self . range_cache . insert ( outpoint. store ( ) , sats) ;
487
- self . outputs_inserted_since_flush += 1 ;
488
- }
489
-
490
- Ok ( ( ) )
491
- }
430
+ // fn index_transaction_sats(
431
+ // &mut self,
432
+ // tx: &Transaction,
433
+ // txid: Txid,
434
+ // sat_to_satpoint: &mut Table<u64, &SatPointValue>,
435
+ // input_sat_ranges: &mut VecDeque<(u64, u64)>,
436
+ // sat_ranges_written: &mut u64,
437
+ // outputs_traversed: &mut u64,
438
+ // inscription_updater: &mut InscriptionUpdater,
439
+ // ) -> Result {
440
+ // inscription_updater.index_transaction_inscriptions(tx, txid, Some(input_sat_ranges))?;
441
+
442
+ // for (vout, output) in tx.output.iter().enumerate() {
443
+ // let outpoint = OutPoint {
444
+ // vout: vout.try_into().unwrap(),
445
+ // txid,
446
+ // };
447
+ // let mut sats = Vec::new();
448
+
449
+ // let mut remaining = output.value;
450
+ // while remaining > 0 {
451
+ // let range = input_sat_ranges.pop_front().ok_or_else(|| {
452
+ // anyhow::anyhow!("insufficient inputs for transaction outputs")
453
+ // })?;
454
+
455
+ // if !Sat(range.0).is_common() {
456
+ // sat_to_satpoint.insert(
457
+ // &range.0,
458
+ // &SatPoint {
459
+ // outpoint,
460
+ // offset: output.value - remaining,
461
+ // }
462
+ // .store(),
463
+ // )?;
464
+ // }
465
+
466
+ // let count = range.1 - range.0;
467
+
468
+ // let assigned = if count > remaining {
469
+ // self.sat_ranges_since_flush += 1;
470
+ // let middle = range.0 + remaining;
471
+ // input_sat_ranges.push_front((middle, range.1));
472
+ // (range.0, middle)
473
+ // } else {
474
+ // range
475
+ // };
476
+
477
+ // sats.extend_from_slice(&assigned.store());
478
+
479
+ // remaining -= assigned.1 - assigned.0;
480
+
481
+ // *sat_ranges_written += 1;
482
+ // }
483
+
484
+ // *outputs_traversed += 1;
485
+
486
+ // self.range_cache.insert(outpoint.store(), sats);
487
+ // self.outputs_inserted_since_flush += 1;
488
+ // }
489
+
490
+ // Ok(())
491
+ // }
492
492
493
493
fn commit ( & mut self , wtx : WriteTransaction , value_cache : HashMap < OutPoint , u64 > ) -> Result {
494
494
println ! (
0 commit comments