tpu now hangs on to its cluster_info

This commit is contained in:
Michael Vines 2019-02-13 15:45:49 -08:00 committed by Grimes
parent dca73068c5
commit 0f8ff07b51
2 changed files with 13 additions and 16 deletions

View File

@ -286,7 +286,7 @@ impl Fullnode {
.broadcast .broadcast
.try_clone() .try_clone()
.expect("Failed to clone broadcast socket"), .expect("Failed to clone broadcast socket"),
cluster_info.clone(), &cluster_info,
config.sigverify_disabled, config.sigverify_disabled,
max_tick_height, max_tick_height,
blob_index, blob_index,
@ -389,7 +389,6 @@ impl Fullnode {
self.broadcast_socket self.broadcast_socket
.try_clone() .try_clone()
.expect("Failed to clone broadcast socket"), .expect("Failed to clone broadcast socket"),
self.cluster_info.clone(),
self.sigverify_disabled, self.sigverify_disabled,
max_tick_height, max_tick_height,
0, 0,
@ -407,7 +406,6 @@ impl Fullnode {
.iter() .iter()
.map(|s| s.try_clone().expect("Failed to clone TPU sockets")) .map(|s| s.try_clone().expect("Failed to clone TPU sockets"))
.collect(), .collect(),
self.cluster_info.clone(),
); );
FullnodeReturnType::LeaderToValidatorRotation FullnodeReturnType::LeaderToValidatorRotation
} }

View File

@ -68,6 +68,7 @@ impl ForwarderServices {
pub struct Tpu { pub struct Tpu {
tpu_mode: Option<TpuMode>, tpu_mode: Option<TpuMode>,
exit: Arc<AtomicBool>, exit: Arc<AtomicBool>,
cluster_info: Arc<RwLock<ClusterInfo>>,
} }
impl Tpu { impl Tpu {
@ -77,7 +78,7 @@ impl Tpu {
tick_duration: PohServiceConfig, tick_duration: PohServiceConfig,
transactions_sockets: Vec<UdpSocket>, transactions_sockets: Vec<UdpSocket>,
broadcast_socket: UdpSocket, broadcast_socket: UdpSocket,
cluster_info: Arc<RwLock<ClusterInfo>>, cluster_info: &Arc<RwLock<ClusterInfo>>,
sigverify_disabled: bool, sigverify_disabled: bool,
max_tick_height: u64, max_tick_height: u64,
blob_index: u64, blob_index: u64,
@ -90,6 +91,7 @@ impl Tpu {
let mut tpu = Self { let mut tpu = Self {
tpu_mode: None, tpu_mode: None,
exit: Arc::new(AtomicBool::new(false)), exit: Arc::new(AtomicBool::new(false)),
cluster_info: cluster_info.clone(),
}; };
if is_leader { if is_leader {
@ -98,7 +100,6 @@ impl Tpu {
tick_duration, tick_duration,
transactions_sockets, transactions_sockets,
broadcast_socket, broadcast_socket,
cluster_info,
sigverify_disabled, sigverify_disabled,
max_tick_height, max_tick_height,
blob_index, blob_index,
@ -108,7 +109,7 @@ impl Tpu {
blocktree, blocktree,
); );
} else { } else {
tpu.switch_to_forwarder(transactions_sockets, cluster_info); tpu.switch_to_forwarder(transactions_sockets);
} }
tpu tpu
@ -126,13 +127,9 @@ impl Tpu {
} }
} }
pub fn switch_to_forwarder( pub fn switch_to_forwarder(&mut self, transactions_sockets: Vec<UdpSocket>) {
&mut self,
transactions_sockets: Vec<UdpSocket>,
cluster_info: Arc<RwLock<ClusterInfo>>,
) {
self.tpu_mode_close(); self.tpu_mode_close();
let tpu_forwarder = TpuForwarder::new(transactions_sockets, cluster_info); let tpu_forwarder = TpuForwarder::new(transactions_sockets, self.cluster_info.clone());
self.tpu_mode = Some(TpuMode::Forwarder(ForwarderServices::new(tpu_forwarder))); self.tpu_mode = Some(TpuMode::Forwarder(ForwarderServices::new(tpu_forwarder)));
} }
@ -143,7 +140,6 @@ impl Tpu {
tick_duration: PohServiceConfig, tick_duration: PohServiceConfig,
transactions_sockets: Vec<UdpSocket>, transactions_sockets: Vec<UdpSocket>,
broadcast_socket: UdpSocket, broadcast_socket: UdpSocket,
cluster_info: Arc<RwLock<ClusterInfo>>,
sigverify_disabled: bool, sigverify_disabled: bool,
max_tick_height: u64, max_tick_height: u64,
blob_index: u64, blob_index: u64,
@ -161,8 +157,11 @@ impl Tpu {
self.exit.clone(), self.exit.clone(),
&packet_sender.clone(), &packet_sender.clone(),
); );
let cluster_info_vote_listener = let cluster_info_vote_listener = ClusterInfoVoteListener::new(
ClusterInfoVoteListener::new(self.exit.clone(), cluster_info.clone(), packet_sender); self.exit.clone(),
self.cluster_info.clone(),
packet_sender,
);
let (sigverify_stage, verified_receiver) = let (sigverify_stage, verified_receiver) =
SigVerifyStage::new(packet_receiver, sigverify_disabled); SigVerifyStage::new(packet_receiver, sigverify_disabled);
@ -180,7 +179,7 @@ impl Tpu {
let broadcast_service = BroadcastService::new( let broadcast_service = BroadcastService::new(
bank.clone(), bank.clone(),
broadcast_socket, broadcast_socket,
cluster_info, self.cluster_info.clone(),
blob_index, blob_index,
bank.leader_scheduler.clone(), bank.leader_scheduler.clone(),
entry_receiver, entry_receiver,