diff --git a/src/banking_stage.rs b/src/banking_stage.rs index d2a34cbd3c..bd0f1ff729 100644 --- a/src/banking_stage.rs +++ b/src/banking_stage.rs @@ -8,7 +8,7 @@ use crate::counter::Counter; use crate::entry::Entry; use crate::packet::Packets; use crate::poh_recorder::{PohRecorder, PohRecorderError}; -use crate::poh_service::{Config, PohService}; +use crate::poh_service::{PohService, PohServiceConfig}; use crate::result::{Error, Result}; use crate::service::Service; use crate::sigverify_stage::VerifiedPackets; @@ -51,7 +51,7 @@ impl BankingStage { pub fn new( bank: &Arc, verified_receiver: Receiver, - config: Config, + config: PohServiceConfig, last_entry_id: &Hash, max_tick_height: u64, leader_id: Pubkey, @@ -338,7 +338,7 @@ mod tests { let (banking_stage, entry_receiver) = BankingStage::new( &bank, verified_receiver, - Config::Sleep(Duration::from_millis(1)), + PohServiceConfig::Sleep(Duration::from_millis(1)), &bank.last_id(), std::u64::MAX, genesis_block.bootstrap_leader_id, diff --git a/src/poh_service.rs b/src/poh_service.rs index 5f59f351a6..82f597ef87 100644 --- a/src/poh_service.rs +++ b/src/poh_service.rs @@ -15,7 +15,7 @@ use std::time::Duration; pub const NUM_TICKS_PER_SECOND: usize = 10; #[derive(Copy, Clone)] -pub enum Config { +pub enum PohServiceConfig { /// * `Tick` - Run full PoH thread. Tick is a rough estimate of how many hashes to roll before /// transmitting a new entry. Tick(usize), @@ -24,10 +24,10 @@ pub enum Config { Sleep(Duration), } -impl Default for Config { - fn default() -> Config { +impl Default for PohServiceConfig { + fn default() -> PohServiceConfig { // TODO: Change this to Tick to enable PoH - Config::Sleep(Duration::from_millis(1000 / NUM_TICKS_PER_SECOND as u64)) + PohServiceConfig::Sleep(Duration::from_millis(1000 / NUM_TICKS_PER_SECOND as u64)) } } @@ -48,7 +48,7 @@ impl PohService { pub fn new( poh_recorder: PohRecorder, - config: Config, + config: PohServiceConfig, to_validator_sender: TpuRotationSender, ) -> Self { // PohService is a headless producer, so when it exits it should notify the banking stage. @@ -80,14 +80,14 @@ impl PohService { fn tick_producer( poh: &mut PohRecorder, - config: Config, + config: PohServiceConfig, poh_exit: &AtomicBool, to_validator_sender: &TpuRotationSender, ) -> Result<()> { let max_tick_height = poh.max_tick_height(); loop { match config { - Config::Tick(num) => { + PohServiceConfig::Tick(num) => { for _ in 1..num { let res = poh.hash(); if let Err(e) = res { @@ -99,7 +99,7 @@ impl PohService { } } } - Config::Sleep(duration) => { + PohServiceConfig::Sleep(duration) => { sleep(duration); } } @@ -128,18 +128,12 @@ impl Service for PohService { #[cfg(test)] mod tests { - use super::{Config, PohService}; + use super::*; use crate::bank::Bank; use crate::genesis_block::GenesisBlock; - use crate::poh_recorder::PohRecorder; - use crate::result::Result; - use crate::service::Service; use crate::test_tx::test_tx; use solana_sdk::hash::hash; - use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::mpsc::channel; - use std::sync::Arc; - use std::thread::{Builder, JoinHandle}; #[test] fn test_poh_service() { @@ -173,8 +167,11 @@ mod tests { const HASHES_PER_TICK: u64 = 2; let (sender, _) = channel(); - let poh_service = - PohService::new(poh_recorder, Config::Tick(HASHES_PER_TICK as usize), sender); + let poh_service = PohService::new( + poh_recorder, + PohServiceConfig::Tick(HASHES_PER_TICK as usize), + sender, + ); // get some events let mut hashes = 0; diff --git a/src/tpu.rs b/src/tpu.rs index 2d8dabe4be..6991192aed 100644 --- a/src/tpu.rs +++ b/src/tpu.rs @@ -7,7 +7,7 @@ use crate::broadcast_service::BroadcastService; use crate::cluster_info::ClusterInfo; use crate::cluster_info_vote_listener::ClusterInfoVoteListener; use crate::fetch_stage::FetchStage; -use crate::poh_service::Config; +use crate::poh_service::PohServiceConfig; use crate::service::Service; use crate::sigverify_stage::SigVerifyStage; use crate::streamer::BlobSender; @@ -77,7 +77,7 @@ impl Tpu { #[allow(clippy::too_many_arguments)] pub fn new( bank: &Arc, - tick_duration: Config, + tick_duration: PohServiceConfig, transactions_sockets: Vec, broadcast_socket: UdpSocket, cluster_info: Arc>, @@ -143,7 +143,7 @@ impl Tpu { pub fn switch_to_leader( &mut self, bank: &Arc, - tick_duration: Config, + tick_duration: PohServiceConfig, transactions_sockets: Vec, broadcast_socket: UdpSocket, cluster_info: Arc>,