self.commit(wtx, value_cache)?;
value_cache = HashMap::new();
uncommitted = 0;
wtx = self.index.begin_write()?;
let height = wtx
.open_table(HEIGHT_TO_BLOCK_HASH)?
.range(0..)?
.next_back()
.and_then(|result| result.ok())
.map(|(height, _hash)| height.value() + 1)
.unwrap_or(0);
if height != self.height {
// another update has run between committing and beginning the new
// write transaction
break;
}
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),
)?;
}
if SHUTTING_DOWN.load(atomic::Ordering::Relaxed) {
break;
}
}
if uncommitted > 0 {
self.commit(wtx, value_cache)?;
}