@@ -250,6 +250,7 @@ pub fn find_lazy_block_at_block_height(
250
250
block_height : u32 ,
251
251
retry : u8 ,
252
252
blocks_db : & DB ,
253
+ ctx : & Context ,
253
254
) -> Option < LazyBlock > {
254
255
let mut attempt = 0 ;
255
256
// let mut read_options = rocksdb::ReadOptions::default();
@@ -265,6 +266,14 @@ pub fn find_lazy_block_at_block_height(
265
266
attempt += 1 ;
266
267
backoff = 2.0 * backoff + ( backoff * rng. gen_range ( 0.0 ..1.0 ) ) ;
267
268
let duration = std:: time:: Duration :: from_millis ( ( backoff * 1_000.0 ) as u64 ) ;
269
+ ctx. try_log ( |logger| {
270
+ slog:: warn!(
271
+ logger,
272
+ "Unable to find block {}, will retry in {:?}" ,
273
+ block_height,
274
+ duration
275
+ )
276
+ } ) ;
268
277
std:: thread:: sleep ( duration) ;
269
278
if attempt > retry {
270
279
return None ;
@@ -496,9 +505,7 @@ pub fn find_all_inscriptions_in_block(
496
505
let ordinal_number: u64 = row. get ( 1 ) . unwrap ( ) ;
497
506
let block_height: u64 = row. get ( 2 ) . unwrap ( ) ;
498
507
let inscription_id: String = row. get ( 3 ) . unwrap ( ) ;
499
- let ( transaction_identifier, input_index) = {
500
- parse_inscription_id ( & inscription_id)
501
- } ;
508
+ let ( transaction_identifier, input_index) = { parse_inscription_id ( & inscription_id) } ;
502
509
let inscription_offset_intra_output: u64 = row. get ( 4 ) . unwrap ( ) ;
503
510
let outpoint_to_watch: String = row. get ( 5 ) . unwrap ( ) ;
504
511
let ( latest_transaction_id, mut output_index) = parse_outpoint_to_watch ( & outpoint_to_watch) ;
@@ -508,7 +515,8 @@ pub fn find_all_inscriptions_in_block(
508
515
slog:: warn!(
509
516
logger,
510
517
"Inscription {} ({}) most likely to end up lost in transfers" ,
511
- inscription_number, inscription_id
518
+ inscription_number,
519
+ inscription_id
512
520
)
513
521
} ) ;
514
522
output_index = 0 ;
@@ -961,31 +969,32 @@ pub fn retrieve_satoshi_point_using_lazy_storage(
961
969
let mut ordinal_block_number = block_identifier. index as u32 ;
962
970
let txid = transaction_identifier. get_8_hash_bytes ( ) ;
963
971
964
- let ( sats_ranges, inscription_offset_cross_outputs) =
965
- match traversals_cache. get ( & ( block_identifier. index as u32 , txid. clone ( ) ) ) {
966
- Some ( entry) => {
967
- let tx = entry. value ( ) ;
968
- (
969
- tx. get_sat_ranges ( ) ,
970
- tx. get_cumulated_sats_in_until_input_index ( input_index) ,
971
- )
972
+ let ( sats_ranges, inscription_offset_cross_outputs) = match traversals_cache
973
+ . get ( & ( block_identifier. index as u32 , txid. clone ( ) ) )
974
+ {
975
+ Some ( entry) => {
976
+ let tx = entry. value ( ) ;
977
+ (
978
+ tx. get_sat_ranges ( ) ,
979
+ tx. get_cumulated_sats_in_until_input_index ( input_index) ,
980
+ )
981
+ }
982
+ None => match find_lazy_block_at_block_height ( ordinal_block_number, 10 , & blocks_db, & ctx) {
983
+ None => {
984
+ return Err ( format ! ( "block #{ordinal_block_number} not in database" ) ) ;
972
985
}
973
- None => match find_lazy_block_at_block_height ( ordinal_block_number, 10 , & blocks_db) {
974
- None => {
975
- return Err ( format ! ( "block #{ordinal_block_number} not in database" ) ) ;
986
+ Some ( block) => match block. find_and_serialize_transaction_with_txid ( & txid) {
987
+ Some ( tx) => {
988
+ let sats_ranges = tx. get_sat_ranges ( ) ;
989
+ let inscription_offset_cross_outputs =
990
+ tx. get_cumulated_sats_in_until_input_index ( input_index) ;
991
+ traversals_cache. insert ( ( ordinal_block_number, txid. clone ( ) ) , tx) ;
992
+ ( sats_ranges, inscription_offset_cross_outputs)
976
993
}
977
- Some ( block) => match block. find_and_serialize_transaction_with_txid ( & txid) {
978
- Some ( tx) => {
979
- let sats_ranges = tx. get_sat_ranges ( ) ;
980
- let inscription_offset_cross_outputs =
981
- tx. get_cumulated_sats_in_until_input_index ( input_index) ;
982
- traversals_cache. insert ( ( ordinal_block_number, txid. clone ( ) ) , tx) ;
983
- ( sats_ranges, inscription_offset_cross_outputs)
984
- }
985
- None => return Err ( format ! ( "txid not in block #{ordinal_block_number}" ) ) ,
986
- } ,
994
+ None => return Err ( format ! ( "txid not in block #{ordinal_block_number}" ) ) ,
987
995
} ,
988
- } ;
996
+ } ,
997
+ } ;
989
998
990
999
for ( i, ( min, max) ) in sats_ranges. into_iter ( ) . enumerate ( ) {
991
1000
if inscription_offset_cross_outputs >= min && inscription_offset_cross_outputs < max {
@@ -1068,13 +1077,13 @@ pub fn retrieve_satoshi_point_using_lazy_storage(
1068
1077
}
1069
1078
}
1070
1079
1071
- let lazy_block = match find_lazy_block_at_block_height ( ordinal_block_number , 10 , & blocks_db )
1072
- {
1073
- Some ( block) => block,
1074
- None => {
1075
- return Err ( format ! ( "block #{ordinal_block_number} not in database" ) ) ;
1076
- }
1077
- } ;
1080
+ let lazy_block =
1081
+ match find_lazy_block_at_block_height ( ordinal_block_number , 10 , & blocks_db , & ctx ) {
1082
+ Some ( block) => block,
1083
+ None => {
1084
+ return Err ( format ! ( "block #{ordinal_block_number} not in database" ) ) ;
1085
+ }
1086
+ } ;
1078
1087
1079
1088
let coinbase_txid = lazy_block. get_coinbase_txid ( ) ;
1080
1089
let txid = tx_cursor. 0 ;
0 commit comments