.open_table(STATISTIC_TO_COUNT)
.unwrap()
.get(&statistic.key())
.unwrap()
.map(|x| x.value())
.unwrap_or(0)
}
pub(crate) fn block_count(&self) -> Result<u32> {
self.begin_read()?.block_count()
}
pub(crate) fn block_height(&self) -> Result<Option<Height>> {
self.begin_read()?.block_height()
}
pub(crate) fn block_hash(&self, height: Option<u32>) -> Result<Option<BlockHash>> {
self.begin_read()?.block_hash(height)
}
pub(crate) fn blocks(&self, take: usize) -> Result<Vec<(u32, BlockHash)>> {
let rtx = self.begin_read()?;
let block_count = rtx.block_count()?;
let height_to_block_hash = rtx.0.open_table(HEIGHT_TO_BLOCK_HASH)?;
let mut blocks = Vec::with_capacity(block_count.try_into().unwrap());
for next in height_to_block_hash.range(0..block_count)?.rev().take(take) {
let next = next?;
blocks.push((next.0.value(), Entry::load(*next.1.value())));
}
Ok(blocks)
}
pub(crate) fn rare_sat_satpoints(&self) -> Result<Vec<(Sat, SatPoint)>> {