Open arik-so opened 1 month ago
If the Self::proxy()
return type were correct, the following spaghetti code might be an approximation:
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>> {
task::block_in_place(|| {
if !index.has_sat_index() {
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 id.is_none() {
if let Some(proxy) = server_config.proxy.as_ref() {
return Self::proxy(proxy, &format!("r/sat/{}/at/{}", sat, inscription_index));
}
}
Ok(Json(api::SatInscription { id }))
})
}
Yes, this is a good idea. I even have an issue for this https://github.com/ordinals/ord/issues/3806
Oh oops, sorry!
The
server --proxy
option is helpful for testing mainnet inscriptions' behavior locally, but a lot of inscriptions that require such testing rely on a specific dynamically inscribed ordinal, which is usually uninscribed locally, and breaks testability.I wonder whether allowing the
--proxy
option to also apply as a fallback for the/r/sat/:sat/at/:index
endpoint might be worth pursuing? That should help with resolving dynamic content.