Skip to content

Commit

Permalink
added suggested error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptoni9n committed Feb 12, 2025
1 parent 052f768 commit e4e5ba2
Showing 1 changed file with 24 additions and 25 deletions.
49 changes: 24 additions & 25 deletions src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2279,31 +2279,30 @@ impl Server {

let parents = ids
.into_iter()
.map(|inscription_id| {
let entry = index
.get_inscription_entry(inscription_id)
.unwrap()
.unwrap();

let satpoint = index
.get_inscription_satpoint_by_id(inscription_id)
.ok()
.flatten()
.unwrap();

api::RelativeInscriptionRecursive {
charms: Charm::charms(entry.charms),
fee: entry.fee,
height: entry.height,
id: inscription_id,
number: entry.inscription_number,
output: satpoint.outpoint,
sat: entry.sat,
satpoint,
timestamp: timestamp(entry.timestamp.into()).timestamp(),
}
})
.collect();
.map(
|inscription_id| -> ServerResult<api::RelativeInscriptionRecursive> {
let entry = index
.get_inscription_entry(inscription_id)?
.ok_or_not_found(|| format!("inscription {inscription_id}"))?;

let satpoint = index
.get_inscription_satpoint_by_id(inscription_id)?
.ok_or_not_found(|| format!("satpoint for inscription {inscription_id}"))?;

Ok(api::RelativeInscriptionRecursive {
charms: Charm::charms(entry.charms),
fee: entry.fee,
height: entry.height,
id: inscription_id,
number: entry.inscription_number,
output: satpoint.outpoint,
sat: entry.sat,
satpoint,
timestamp: timestamp(entry.timestamp.into()).timestamp(),
})
},
)
.collect::<Result<Vec<_>, _>>()?;

Ok(
Json(api::ParentInscriptions {
Expand Down

0 comments on commit e4e5ba2

Please sign in to comment.