Skip to content
Snippets Groups Projects
Unverified Commit d31bb8ac authored by yjh's avatar yjh Committed by GitHub
Browse files

chore: fast return for invalid request of node health (#5762)

Co-authored-by: command-bot <>
parent b230b0e3
No related merge requests found
Pipeline #497865 waiting for manual action with stages
in 1 hour, 24 minutes, and 23 seconds
title: Fast return for invalid request of node health
doc:
- audience: Node Dev
description: |
Return directly when invalid request for node health api
crates:
- name: sc-rpc-server
bump: patch
......@@ -98,17 +98,17 @@ where
let fut = self.0.call(req);
async move {
let res = fut.await.map_err(|err| err.into())?;
Ok(match maybe_intercept {
InterceptRequest::Deny =>
http_response(StatusCode::METHOD_NOT_ALLOWED, HttpBody::empty()),
InterceptRequest::No => res,
InterceptRequest::No => fut.await.map_err(|err| err.into())?,
InterceptRequest::Health => {
let res = fut.await.map_err(|err| err.into())?;
let health = parse_rpc_response(res.into_body()).await?;
http_ok_response(serde_json::to_string(&health)?)
},
InterceptRequest::Readiness => {
let res = fut.await.map_err(|err| err.into())?;
let health = parse_rpc_response(res.into_body()).await?;
if (!health.is_syncing && health.peers > 0) || !health.should_have_peers {
http_ok_response(HttpBody::empty())
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment