Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions beacon_node/builder_client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use eth2::types::{
};
use eth2::types::{FullPayloadContents, SignedBlindedBeaconBlock};
pub use eth2::Error;
use eth2::{ok_or_error, StatusCode};
use eth2::{ok_or_error, StatusCode, CONSENSUS_VERSION_HEADER};
use reqwest::header::{HeaderMap, HeaderValue};
use reqwest::{IntoUrl, Response};
use sensitive_url::SensitiveUrl;
use serde::de::DeserializeOwned;
Expand Down Expand Up @@ -108,13 +109,20 @@ impl BuilderHttpClient {
&self,
url: U,
body: &T,
headers: HeaderMap,
timeout: Option<Duration>,
) -> Result<Response, Error> {
let mut builder = self.client.post(url);
if let Some(timeout) = timeout {
builder = builder.timeout(timeout);
}
let response = builder.json(body).send().await.map_err(Error::from)?;

let response = builder
.headers(headers)
.json(body)
.send()
.await
.map_err(Error::from)?;
ok_or_error(response).await
}

Expand Down Expand Up @@ -151,10 +159,16 @@ impl BuilderHttpClient {
.push("builder")
.push("blinded_blocks");

let mut headers = HeaderMap::new();
if let Ok(value) = HeaderValue::from_str(&blinded_block.fork_name_unchecked().to_string()) {
headers.insert(CONSENSUS_VERSION_HEADER, value);
}

Ok(self
.post_with_raw_response(
path,
&blinded_block,
headers,
Some(self.timeouts.post_blinded_blocks),
)
.await?
Expand Down