Skip to content

Commit

Permalink
fix(rooch-da): avoid unnecessary cursor updates (#3198)
Browse files Browse the repository at this point in the history
Ensure cursor updates only when necessary to reduce disk I/O and avoid misleading update times. Added a condition to compare the current cursor with the last block number before updating.
  • Loading branch information
popcnt1 authored Jan 16, 2025
1 parent 046b416 commit 2f106fa
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion crates/rooch-da/src/actor/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,14 @@ impl BackgroundSubmitter {

// there is no unsubmitted block
if unsubmitted_blocks.is_empty() {
self.update_cursor(last_block_number)?;
// if no changes, don't update cursor,
// avoid unnecessary disk I/O and misleading update time
if let Some(origin_cursor) = origin_background_cursor {
if origin_cursor != last_block_number {
// update cursor to last_block_number, because cursor maybe behind than set_submitting_block_done
self.update_cursor(last_block_number)?;
}
}
return Ok(());
}
let first_unsubmitted_block = unsubmitted_blocks.first().unwrap().block_number;
Expand Down

0 comments on commit 2f106fa

Please sign in to comment.