mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-09 11:25:55 +00:00
Refactor timestamp_now (#9094)
#9077 Where possible replaces all instances of `validator_monitor::timestamp_now` with `chain.slot_clock.now_duration().unwrap_or_default()`. Where chain/slot_clock is not available, instead replace it with a convenience function `slot_clock::timestamp_now`. Remove the `validator_monitor::timestamp_now` function. Co-Authored-By: Mac L <mjladson@pm.me>
This commit is contained in:
@@ -4,7 +4,7 @@ use std::future::Future;
|
||||
use beacon_chain::blob_verification::{GossipBlobError, GossipVerifiedBlob};
|
||||
use beacon_chain::block_verification_types::{AsBlock, LookupBlock};
|
||||
use beacon_chain::data_column_verification::GossipVerifiedDataColumn;
|
||||
use beacon_chain::validator_monitor::{get_block_delay_ms, timestamp_now};
|
||||
use beacon_chain::validator_monitor::get_block_delay_ms;
|
||||
use beacon_chain::{
|
||||
AvailabilityProcessingStatus, BeaconChain, BeaconChainError, BeaconChainTypes, BlockError,
|
||||
IntoGossipVerifiedBlock, NotifyExecutionLayer, build_blob_data_column_sidecars,
|
||||
@@ -19,6 +19,7 @@ use lighthouse_network::PubsubMessage;
|
||||
use network::NetworkMessage;
|
||||
use rand::prelude::SliceRandom;
|
||||
use reqwest::StatusCode;
|
||||
use slot_clock::SlotClock;
|
||||
use std::marker::PhantomData;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
@@ -88,7 +89,7 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlock<T>>(
|
||||
validation_level: BroadcastValidation,
|
||||
duplicate_status_code: StatusCode,
|
||||
) -> Result<Response, Rejection> {
|
||||
let seen_timestamp = timestamp_now();
|
||||
let seen_timestamp = chain.slot_clock.now_duration().unwrap_or_default();
|
||||
let block_publishing_delay_for_testing = chain.config.block_publishing_delay;
|
||||
let data_column_publishing_delay_for_testing = chain.config.data_column_publishing_delay;
|
||||
|
||||
@@ -113,11 +114,12 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlock<T>>(
|
||||
debug!("Signed block received in HTTP API");
|
||||
|
||||
/* actually publish a block */
|
||||
let publish_chain = chain.clone();
|
||||
let publish_block_p2p = move |block: Arc<SignedBeaconBlock<T::EthSpec>>,
|
||||
sender,
|
||||
seen_timestamp|
|
||||
-> Result<(), BlockError> {
|
||||
let publish_timestamp = timestamp_now();
|
||||
let publish_timestamp = publish_chain.slot_clock.now_duration().unwrap_or_default();
|
||||
let publish_delay = publish_timestamp
|
||||
.checked_sub(seen_timestamp)
|
||||
.unwrap_or_else(|| Duration::from_secs(0));
|
||||
@@ -676,7 +678,7 @@ pub async fn reconstruct_block<T: BeaconChainTypes>(
|
||||
// us.
|
||||
late_block_logging(
|
||||
&chain,
|
||||
timestamp_now(),
|
||||
chain.slot_clock.now_duration().unwrap_or_default(),
|
||||
block.message(),
|
||||
block_root,
|
||||
"builder",
|
||||
|
||||
Reference in New Issue
Block a user