Skip to content

Commit

Permalink
refactor: all routes working
Browse files Browse the repository at this point in the history
  • Loading branch information
tchataigner committed Aug 26, 2024
1 parent d2e50f0 commit 886c011
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions ethereum/light-client/src/bin/proof_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,13 @@ async fn inclusion_proof(

async fn committee_proof(
State(state): State<ServerState>,
Json(payload): Json<ProofRequestPayload>,
request: axum::extract::Request,
) -> Result<impl IntoResponse, StatusCode> {
let res = Request::from_bytes(&payload.request_bytes);
let bytes = axum::body::to_bytes(request.into_body(), usize::MAX)
.await
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;

let res = Request::from_bytes(&bytes);

if let Err(err) = res {
error!("Failed to deserialize request object: {err}");
Expand All @@ -183,7 +187,7 @@ async fn committee_proof(
}
Mode::Split => {
let snd_addr = state.snd_addr.as_ref().clone().unwrap();
forward_request(&payload.request_bytes, &snd_addr).await
forward_request(&bytes, &snd_addr).await
}
}
} else {
Expand All @@ -205,9 +209,13 @@ async fn committee_proof(

async fn inclusion_verify(
State(state): State<ServerState>,
Json(payload): Json<ProofRequestPayload>,
request: axum::extract::Request,
) -> Result<impl IntoResponse, StatusCode> {
let res = Request::from_bytes(&payload.request_bytes);
let bytes = axum::body::to_bytes(request.into_body(), usize::MAX)
.await
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;

let res = Request::from_bytes(&bytes);

if let Err(err) = res {
error!("Failed to deserialize request object: {err}");
Expand Down Expand Up @@ -237,9 +245,13 @@ async fn inclusion_verify(

async fn committee_verify(
State(state): State<ServerState>,
Json(payload): Json<ProofRequestPayload>,
request: axum::extract::Request,
) -> Result<impl IntoResponse, StatusCode> {
let res = Request::from_bytes(&payload.request_bytes);
let bytes = axum::body::to_bytes(request.into_body(), usize::MAX)
.await
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;

let res = Request::from_bytes(&bytes);

if let Err(err) = res {
error!("Failed to deserialize request object: {err}");
Expand Down

0 comments on commit 886c011

Please sign in to comment.