diff --git a/src/api/api.rs b/src/api/api.rs index c34eee1..20b7ec4 100644 --- a/src/api/api.rs +++ b/src/api/api.rs @@ -118,6 +118,13 @@ impl PhotonApi { .map_err(Into::into) } + pub async fn health(&self) -> Result<(), PhotonApiError> { + self.get_indexer_health() + .await + .map(|_| ()) + .map_err(Into::into) + } + pub async fn get_compressed_account( &self, request: CompressedAccountRequest, diff --git a/src/api/rpc_server.rs b/src/api/rpc_server.rs index d3c95e1..96a2ea5 100644 --- a/src/api/rpc_server.rs +++ b/src/api/rpc_server.rs @@ -19,7 +19,8 @@ pub async fn run_server(api: PhotonApi, port: u16) -> Result Result, api.readiness().await.map_err(Into::into) })?; + module.register_async_method("health", |_rpc_params, rpc_context| async move { + debug!("Checking Health"); + let api = rpc_context.as_ref(); + api.health().await.map_err(Into::into) + })?; + + module.register_async_method( "getCompressedAccount", |rpc_params, rpc_context| async move {