mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 08:52:54 +00:00
remove methods to post without content header
This commit is contained in:
@@ -389,53 +389,6 @@ impl BeaconNodeHttpClient {
|
|||||||
ok_or_error(response).await
|
ok_or_error(response).await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generic POST function supporting arbitrary responses and timeouts.
|
|
||||||
/// Does not include Content-Type application/json in the request header.
|
|
||||||
async fn post_generic_json_without_content_type_header<T: Serialize, U: IntoUrl>(
|
|
||||||
&self,
|
|
||||||
url: U,
|
|
||||||
body: &T,
|
|
||||||
timeout: Option<Duration>,
|
|
||||||
) -> Result<Response, Error> {
|
|
||||||
let mut builder = self.client.post(url);
|
|
||||||
if let Some(timeout) = timeout {
|
|
||||||
builder = builder.timeout(timeout);
|
|
||||||
}
|
|
||||||
|
|
||||||
let serialized_body = serde_json::to_vec(body).map_err(Error::InvalidJson)?;
|
|
||||||
|
|
||||||
let response = builder.body(serialized_body).send().await?;
|
|
||||||
ok_or_error(response).await
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Generic POST function supporting arbitrary responses and timeouts.
|
|
||||||
/// Does not include Content-Type application/json in the request header.
|
|
||||||
/// Does include Eth-Consensus-Version in the request header.
|
|
||||||
async fn post_generic_json_without_content_type_header_but_with_consensus_header<
|
|
||||||
T: Serialize,
|
|
||||||
U: IntoUrl,
|
|
||||||
>(
|
|
||||||
&self,
|
|
||||||
url: U,
|
|
||||||
body: &T,
|
|
||||||
timeout: Option<Duration>,
|
|
||||||
fork: ForkName,
|
|
||||||
) -> Result<Response, Error> {
|
|
||||||
let mut builder = self.client.post(url);
|
|
||||||
if let Some(timeout) = timeout {
|
|
||||||
builder = builder.timeout(timeout);
|
|
||||||
}
|
|
||||||
|
|
||||||
let serialized_body = serde_json::to_vec(body).map_err(Error::InvalidJson)?;
|
|
||||||
|
|
||||||
let response = builder
|
|
||||||
.header(CONSENSUS_VERSION_HEADER, fork.to_string())
|
|
||||||
.body(serialized_body)
|
|
||||||
.send()
|
|
||||||
.await?;
|
|
||||||
ok_or_error(response).await
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Generic POST function supporting arbitrary responses and timeouts.
|
/// Generic POST function supporting arbitrary responses and timeouts.
|
||||||
async fn post_generic_with_consensus_version<T: Serialize, U: IntoUrl>(
|
async fn post_generic_with_consensus_version<T: Serialize, U: IntoUrl>(
|
||||||
&self,
|
&self,
|
||||||
@@ -1382,8 +1335,7 @@ impl BeaconNodeHttpClient {
|
|||||||
.push("pool")
|
.push("pool")
|
||||||
.push("attester_slashings");
|
.push("attester_slashings");
|
||||||
|
|
||||||
self.post_generic_json_without_content_type_header(path, slashing, None)
|
self.post_generic(path, slashing, None).await?;
|
||||||
.await?;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -1402,10 +1354,8 @@ impl BeaconNodeHttpClient {
|
|||||||
.push("pool")
|
.push("pool")
|
||||||
.push("attester_slashings");
|
.push("attester_slashings");
|
||||||
|
|
||||||
self.post_generic_json_without_content_type_header_but_with_consensus_header(
|
self.post_generic_with_consensus_version(path, slashing, None, fork_name)
|
||||||
path, slashing, None, fork_name,
|
.await?;
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user