Ok(Updater {
range_cache: HashMap::new(),
height: index.block_count()?,
index,
sat_ranges_since_flush: 0,
outputs_cached: 0,
outputs_inserted_since_flush: 0,
outputs_traversed: 0,
})
}
pub(crate) fn update_index(&mut self) -> Result {
let mut wtx = self.index.begin_write()?;
let starting_height = u32::try_from(self.index.client.get_block_count()?).unwrap() + 1;
wtx
.open_table(WRITE_TRANSACTION_STARTING_BLOCK_COUNT_TO_TIMESTAMP)?
.insert(
&self.height,
&SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.map(|duration| duration.as_millis())
.unwrap_or(0),
)?;
let mut progress_bar = if cfg!(test)
|| log_enabled!(log::Level::Info)
|| starting_height <= self.height
|| integration_test()
{
None
} else {
let progress_bar = ProgressBar::new(starting_height.into());
progress_bar.set_position(self.height.into());
progress_bar.set_style(