Rename enum Config to enum PohServiceConfig
This commit is contained in:
parent
ab3dd2a1b3
commit
a6aaca814c
|
@ -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<Bank>,
|
||||
verified_receiver: Receiver<VerifiedPackets>,
|
||||
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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<Bank>,
|
||||
tick_duration: Config,
|
||||
tick_duration: PohServiceConfig,
|
||||
transactions_sockets: Vec<UdpSocket>,
|
||||
broadcast_socket: UdpSocket,
|
||||
cluster_info: Arc<RwLock<ClusterInfo>>,
|
||||
|
@ -143,7 +143,7 @@ impl Tpu {
|
|||
pub fn switch_to_leader(
|
||||
&mut self,
|
||||
bank: &Arc<Bank>,
|
||||
tick_duration: Config,
|
||||
tick_duration: PohServiceConfig,
|
||||
transactions_sockets: Vec<UdpSocket>,
|
||||
broadcast_socket: UdpSocket,
|
||||
cluster_info: Arc<RwLock<ClusterInfo>>,
|
||||
|
|
Loading…
Reference in New Issue