Skip to content

Commit

Permalink
Proxy recursive satoshi endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
arik-so committed Nov 21, 2024
1 parent b0e7b20 commit 0375550
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2215,18 +2215,26 @@ impl Server {

async fn sat_inscription_at_index(
Extension(index): Extension<Arc<Index>>,
Extension(server_config): Extension<Arc<ServerConfig>>,
Path((DeserializeFromStr(sat), inscription_index)): Path<(DeserializeFromStr<Sat>, isize)>,
) -> ServerResult<Json<api::SatInscription>> {
) -> ServerResult {
task::block_in_place(|| {
if !index.has_sat_index() {
return Err(ServerError::NotFound(
"this server has no sat index".to_string(),
));
return if let Some(proxy) = server_config.proxy.as_ref() {
Self::proxy(proxy, &format!("r/sat/{}/at/{}", sat, inscription_index))
} else {
Err(ServerError::NotFound(
"this server has no sat index".to_string(),
))
};
}

let id = index.get_inscription_id_by_sat_indexed(sat, inscription_index)?;
if let (Some(proxy), None) = (server_config.proxy.as_ref(), id) {
return Self::proxy(proxy, &format!("r/sat/{}/at/{}", sat, inscription_index));
}

Ok(Json(api::SatInscription { id }))
Ok(Json(api::SatInscription { id }).into_response())
})
}

Expand Down

0 comments on commit 0375550

Please sign in to comment.