Skip to content

Commit

Permalink
Add timestamp header to builder API block-header request
Browse files Browse the repository at this point in the history
  • Loading branch information
Tumas committed Feb 19, 2025
1 parent 0ca3859 commit e604e7b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion builder_api/src/api.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use core::time::Duration;
use std::sync::Arc;
use std::{sync::Arc, time::SystemTime};

use anyhow::{bail, ensure, Result};
use arc_swap::ArcSwap;
Expand Down Expand Up @@ -38,6 +38,7 @@ use crate::{
BuilderApiFormat, BuilderConfig,
};

const DATE_MS_HEADER: &str = "Date-Milliseconds";
const REQUEST_TIMEOUT: Duration = Duration::from_secs(BUILDER_PROPOSAL_DELAY_TOLERANCE);

#[derive(Debug, Error)]
Expand Down Expand Up @@ -237,6 +238,14 @@ impl Api {
)
};

let request = match SystemTime::now().duration_since(SystemTime::UNIX_EPOCH) {
Ok(timestamp) => request.header(DATE_MS_HEADER, format!("{}", timestamp.as_millis())),
Err(error) => {
debug!("unable to calculate timestamp: {error:?}");
request
}
};

let response = request.send().await?;
let response = handle_error(response).await?;

Expand Down

0 comments on commit e604e7b

Please sign in to comment.