Skip to content

Commit

Permalink
consensus: use get_current_timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
fed-franz committed Aug 21, 2024
1 parent a30c00a commit 282063c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
4 changes: 2 additions & 2 deletions consensus/src/proposal/block_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//
// Copyright (c) DUSK NETWORK. All rights reserved.

use crate::commons::{get_current_timestamp, RoundUpdate};
use crate::commons::RoundUpdate;
use crate::operations::{CallParams, Operations, Voter};
use node_data::ledger::{
to_str, Attestation, Block, Fault, IterationsInfo, Seed, Slash,
Expand All @@ -15,9 +15,9 @@ use crate::merkle::merkle_root;

use crate::config::MINIMUM_BLOCK_TIME;
use dusk_bytes::Serializable;
use node_data::ledger;
use node_data::message::payload::Candidate;
use node_data::message::{ConsensusHeader, Message, SignInfo, StepMessage};
use node_data::{get_current_timestamp, ledger};
use std::sync::Arc;
use std::time::Instant;
use tracing::{debug, info};
Expand Down
8 changes: 3 additions & 5 deletions consensus/src/proposal/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ use crate::commons::{ConsensusError, Database};
use crate::execution_ctx::ExecutionCtx;
use crate::msg_handler::{HandleMsgOutput, MsgHandler};
use crate::operations::Operations;
use node_data::get_current_timestamp;
use node_data::ledger::IterationsInfo;
use node_data::message::Message;
use std::cmp;
use std::sync::Arc;
use std::time::{Duration, SystemTime, UNIX_EPOCH};
use std::time::Duration;
use tokio::sync::Mutex;

use crate::config;
Expand Down Expand Up @@ -109,10 +110,7 @@ impl<T: Operations + 'static, D: Database> ProposalStep<T, D> {

/// Waits until the next slot is reached
async fn wait_until_next_slot(tip_timestamp: u64) {
let current_time_secs = SystemTime::now()
.duration_since(UNIX_EPOCH)
.expect("valid unix epoch")
.as_secs();
let current_time_secs = get_current_timestamp();

let next_slot_timestamp = tip_timestamp + MINIMUM_BLOCK_TIME;
if current_time_secs >= next_slot_timestamp {
Expand Down
6 changes: 2 additions & 4 deletions consensus/src/ratification/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@
//
// Copyright (c) DUSK NETWORK. All rights reserved.

use crate::commons::{
get_current_timestamp, ConsensusError, Database, RoundUpdate,
};
use crate::commons::{ConsensusError, Database, RoundUpdate};
use crate::execution_ctx::ExecutionCtx;
use crate::operations::Operations;
use std::marker::PhantomData;

use crate::msg_handler::{HandleMsgOutput, MsgHandler};
use crate::ratification::handler;
use node_data::message;
use node_data::message::payload::{self, ValidationResult};
use node_data::message::{AsyncQueue, Message, Payload, StepMessage};
use node_data::{get_current_timestamp, message};
use std::sync::Arc;
use tokio::sync::Mutex;

Expand Down

0 comments on commit 282063c

Please sign in to comment.