let mut inscription_to_fee: Vec<(InscriptionId, u64)> = Vec::new();
for id in &inscription_ids {
inscription_to_fee.push((
*id,
self
.get_inscription_entry(*id)?
.ok_or_else(|| anyhow!("could not get entry for inscription {id}"))?
.fee,
));
}
inscription_to_fee.sort_by_key(|(_, fee)| *fee);
Ok((
inscription_to_fee
.iter()
.map(|(id, _)| *id)
.rev()
.take(n)
.collect(),
inscription_ids.len(),
))
}
pub(crate) fn get_home_inscriptions(&self) -> Result<Vec<InscriptionId>> {
Ok(
self
.database
.begin_read()?
.open_table(HOME_INSCRIPTIONS)?
.iter()?
.rev()
.flat_map(|result| result.map(|(_number, id)| InscriptionId::load(id.value())))
.collect(),
)
}
pub(crate) fn get_feed_inscriptions(&self, n: usize) -> Result<Vec<(u32, InscriptionId)>> {
Ok(
self
.database
.begin_read()?
.open_table(SEQUENCE_NUMBER_TO_INSCRIPTION_ENTRY)?