Skip to content

Commit

Permalink
Commit every 1000 blocks instead of every block (ordinals#496)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Sep 8, 2022
1 parent 411f7f0 commit 8af196d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,24 +122,32 @@ impl Index {
}

pub(crate) fn index_ranges(&self) -> Result {
let mut block = 0;
let mut wtx = self.database.begin_write()?;

loop {
if let Some(height_limit) = self.height_limit {
if self.height()? >= height_limit {
break;
}
}

let mut wtx = self.database.begin_write()?;

let done = self.index_block(&mut wtx)?;

wtx.commit()?;
if block % 1000 == 0 {
wtx.commit()?;
wtx = self.database.begin_write()?;
}

if done || INTERRUPTS.load(atomic::Ordering::Relaxed) > 0 {
break;
}

block += 1;
}

wtx.commit()?;

Ok(())
}

Expand Down

0 comments on commit 8af196d

Please sign in to comment.