fix: faucet health check uses JSON-RPC instead of REST

The synord RPC server is JSON-RPC only, not REST. Changed health
check from GET /health to POST with synor_getInfo method.
This commit is contained in:
Gulshan Yadav 2026-02-02 02:31:14 +05:30
parent cca23a4019
commit 33fd1a015f

View file

@ -600,16 +600,45 @@ async fn faucet(
} }
} }
/// Check if the RPC node is reachable. /// Check if the RPC node is reachable via JSON-RPC.
async fn check_rpc_connection(state: &FaucetState) -> bool { async fn check_rpc_connection(state: &FaucetState) -> bool {
let url = format!("{}/health", state.config.rpc_url); #[derive(Serialize)]
state struct RpcRequest {
jsonrpc: &'static str,
method: &'static str,
params: Vec<()>,
id: u64,
}
#[derive(Deserialize)]
struct RpcResponse {
result: Option<serde_json::Value>,
#[allow(dead_code)]
error: Option<serde_json::Value>,
}
let request = RpcRequest {
jsonrpc: "2.0",
method: "synor_getInfo",
params: vec![],
id: 1,
};
let response = match state
.http_client .http_client
.get(&url) .post(&state.config.rpc_url)
.json(&request)
.send() .send()
.await .await
.map(|r| r.status().is_success()) {
.unwrap_or(false) Ok(r) if r.status().is_success() => r,
_ => return false,
};
match response.json::<RpcResponse>().await {
Ok(resp) => resp.result.is_some(),
Err(_) => false,
}
} }
/// Validate Synor address format. /// Validate Synor address format.