Skip to content

Commit

Permalink
fix: attempt to fix race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
Ludo Galabru committed Jan 4, 2024
1 parent 3904057 commit d7a986f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ pub fn start_inscription_indexing_processor(
let mut inscriptions_db_conn_rw =
open_readwrite_ordhook_db_conn(&config.expected_cache_path(), &ctx).unwrap();
let ordhook_config = config.get_ordhook_config();
let blocks_db_rw =
open_ordhook_db_conn_rocks_db_loop(true, &config.expected_cache_path(), &ctx);
let mut empty_cycles = 0;

let inscriptions_db_conn =
Expand Down Expand Up @@ -105,11 +103,12 @@ pub fn start_inscription_indexing_processor(
},
};

// Early return
if blocks.is_empty() {
store_compacted_blocks(compacted_blocks, true, &blocks_db_rw, &ctx);
continue;
} else {
{
let blocks_db_rw = open_ordhook_db_conn_rocks_db_loop(
true,
&config.expected_cache_path(),
&ctx,
);
store_compacted_blocks(
compacted_blocks,
true,
Expand All @@ -118,8 +117,12 @@ pub fn start_inscription_indexing_processor(
);
}

ctx.try_log(|logger| info!(logger, "Processing {} blocks", blocks.len()));
// Early return
if blocks.is_empty() {
continue;
}

ctx.try_log(|logger| info!(logger, "Processing {} blocks", blocks.len()));
blocks = process_blocks(
&mut blocks,
&mut sequence_cursor,
Expand All @@ -131,7 +134,6 @@ pub fn start_inscription_indexing_processor(
);

garbage_collect_nth_block += blocks.len();

if garbage_collect_nth_block > garbage_collect_every_n_blocks {
ctx.try_log(|logger| info!(logger, "Performing garbage collecting"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ pub fn compute_satoshi_number(
) {
Some(block) => break block,
None => {
return Err(format!("block #{ordinal_block_number} not in database"));
return Err(format!("block #{ordinal_block_number} not in database (traversing {} / {} in progress)", transaction_identifier.hash, block_identifier.index));
}
}
}
Expand Down

0 comments on commit d7a986f

Please sign in to comment.