let entry = match rtx.open_table(RUNE_TO_RUNE_ID)?.get(rune.0)? {
Some(id) => rtx
.open_table(RUNE_ID_TO_RUNE_ENTRY)?
.get(id.value())?
.map(|entry| (RuneId::load(id.value()), RuneEntry::load(entry.value()))),
None => None,
};
Ok(entry)
}
pub(crate) fn runes(&self) -> Result<Vec<(RuneId, RuneEntry)>> {
let mut entries = Vec::new();
for result in self
.database
.begin_read()?
.open_table(RUNE_ID_TO_RUNE_ENTRY)?
.iter()?
{
let (id, entry) = result?;
entries.push((RuneId::load(id.value()), RuneEntry::load(entry.value())));
}
Ok(entries)
}
pub(crate) fn get_rune_balances_for_outpoint(
&self,
outpoint: OutPoint,
) -> Result<Vec<(Rune, Pile)>> {
let rtx = self.database.begin_read()?;
let outpoint_to_balances = rtx.open_table(OUTPOINT_TO_RUNE_BALANCES)?;
let id_to_rune_entries = rtx.open_table(RUNE_ID_TO_RUNE_ENTRY)?;
let Some(balances) = outpoint_to_balances.get(&outpoint.store())? else {