Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy recursive satoshi endpoint #4022

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading