Skip to content

Commit d9d4951

Browse files
committed
chore: use chrono, debug
1 parent b8ba0fe commit d9d4951

File tree

5 files changed

+12
-5
lines changed

5 files changed

+12
-5
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ openssl = { version = "0.10", features = ["vendored"] }
5454
reqwest = { version = "0.11.24", features = ["blocking", "json"] }
5555
serde_json = "1.0"
5656
tokio = { version = "1.36.0", features = ["full", "macros", "rt-multi-thread"] }
57+
chrono = "0.4.40"
5758

5859
tokio-stream = "0.1.17"
5960
url = "2.5.4"

src/tasks/block/sim.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,14 @@ impl Simulator {
219219
let deadline =
220220
Instant::now() + Duration::from_secs(remaining) - Duration::from_millis(2500);
221221

222+
debug!(
223+
timepoint,
224+
remaining,
225+
timestamp = chrono::Utc::now().timestamp(),
226+
deadline = ?deadline,
227+
"calculated deadline for block simulation"
228+
);
229+
222230
deadline.max(Instant::now())
223231
}
224232

src/tasks/submit/task.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,7 @@ impl SubmitTask {
214214

215215
/// Calculates and returns the slot number and its start and end timestamps for the current instant.
216216
fn calculate_slot_window(&self) -> (u64, u64, u64) {
217-
let now_ts = utils::now();
218-
let current_slot = self.config.slot_calculator.calculate_slot(now_ts);
217+
let current_slot = self.config.slot_calculator.current_slot();
219218
let (start, end) = self.config.slot_calculator.calculate_slot_window(current_slot);
220219
(current_slot, start, end)
221220
}

src/utils.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@ use alloy::{
66
};
77
use signet_sim::BuiltBlock;
88
use signet_zenith::BundleHelper::FillPermit2;
9-
use std::time::UNIX_EPOCH;
109

1110
/// Returns the current timestamp in seconds since the UNIX epoch.
1211
pub(crate) fn now() -> u64 {
13-
let now = std::time::SystemTime::now();
14-
now.duration_since(UNIX_EPOCH).unwrap().as_secs()
12+
chrono::Utc::now().timestamp() as u64
1513
}
1614

1715
// This function converts &[SignedFill] into [FillPermit2]

0 commit comments

Comments
 (0)