Finish implementing exit on tpu service
This commit is contained in:
parent
b65c77a93b
commit
40309d8f58
|
@ -8,8 +8,6 @@ use std::{
|
|||
|
||||
use anyhow::{bail, Context};
|
||||
use chrono::{TimeZone, Utc};
|
||||
|
||||
use jsonrpsee::SubscriptionSink;
|
||||
use log::{error, info, trace};
|
||||
use prometheus::{
|
||||
core::GenericGauge, histogram_opts, opts, register_histogram, register_int_counter,
|
||||
|
|
|
@ -174,7 +174,7 @@ impl TpuService {
|
|||
async fn update_current_slot(
|
||||
&self,
|
||||
update_notifier: tokio::sync::mpsc::UnboundedSender<u64>,
|
||||
) -> anyhow::Result<()> {
|
||||
) {
|
||||
let current_slot = self.current_slot.clone();
|
||||
let update_slot = |slot: u64| {
|
||||
if slot > current_slot.load(Ordering::Relaxed) {
|
||||
|
@ -185,6 +185,9 @@ impl TpuService {
|
|||
};
|
||||
|
||||
loop {
|
||||
if self.check_exit_signal() {
|
||||
break;
|
||||
}
|
||||
// always loop update the current slots as it is central to working of TPU
|
||||
let _ = SolanaUtils::poll_slots(
|
||||
self.rpc_client.clone(),
|
||||
|
@ -230,14 +233,13 @@ impl TpuService {
|
|||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
});
|
||||
|
||||
let this = self.clone();
|
||||
let (slot_sender, slot_reciever) = tokio::sync::mpsc::unbounded_channel::<Slot>();
|
||||
|
||||
let slot_sub_task: AnyhowJoinHandle = tokio::spawn(async move {
|
||||
this.update_current_slot(slot_sender).await?;
|
||||
this.update_current_slot(slot_sender).await;
|
||||
Ok(())
|
||||
});
|
||||
|
||||
|
@ -284,4 +286,8 @@ impl TpuService {
|
|||
pub fn get_estimated_slot_holder(&self) -> Arc<AtomicU64> {
|
||||
self.estimated_slot.clone()
|
||||
}
|
||||
|
||||
pub fn exit(&self) {
|
||||
self.exit_signal.store(true, Ordering::Relaxed);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue