Skip to content

Commit af03289

Browse files
authored
Merge pull request #4163 from ProvableHQ/fix/clean_bootstrapper_shutdown
[Fix] Allow the BootstrapClient to shut down cleanly on SIGINT
2 parents d56de20 + 665665f commit af03289

File tree

1 file changed

+2
-20
lines changed
  • node/src/bootstrap_client

1 file changed

+2
-20
lines changed

node/src/bootstrap_client/mod.rs

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,9 @@ use snarkvm::{
2929
};
3030

3131
#[cfg(feature = "locktick")]
32-
use locktick::{
33-
parking_lot::{Mutex, RwLock},
34-
tokio::Mutex as TMutex,
35-
};
32+
use locktick::{parking_lot::RwLock, tokio::Mutex as TMutex};
3633
#[cfg(not(feature = "locktick"))]
37-
use parking_lot::{Mutex, RwLock};
34+
use parking_lot::RwLock;
3835
use std::{
3936
collections::{HashMap, HashSet},
4037
net::SocketAddr,
@@ -45,7 +42,6 @@ use std::{
4542
};
4643
#[cfg(not(feature = "locktick"))]
4744
use tokio::sync::Mutex as TMutex;
48-
use tokio::sync::oneshot;
4945

5046
#[derive(Clone)]
5147
pub struct BootstrapClient<N: Network>(Arc<InnerBootstrapClient<N>>);
@@ -72,7 +68,6 @@ pub struct InnerBootstrapClient<N: Network> {
7268
http_client: reqwest::Client,
7369
latest_committee: TMutex<(HashSet<Address<N>>, Instant)>,
7470
dev: Option<u16>,
75-
shutdown_tx: Mutex<Option<oneshot::Sender<()>>>,
7671
}
7772

7873
impl<N: Network> BootstrapClient<N> {
@@ -104,10 +99,6 @@ impl<N: Network> BootstrapClient<N> {
10499
// Prepare a placeholder committee, ensuring that it's insta-outdated.
105100
let latest_committee = TMutex::new((Default::default(), Instant::now() - Self::COMMITTEE_REFRESH_TIME));
106101

107-
// Prepare the shutdown channel.
108-
let (shutdown_tx, shutdown_rx) = oneshot::channel();
109-
let shutdown_tx = Mutex::new(Some(shutdown_tx));
110-
111102
// Construct and return the bootstrap client.
112103
let inner = InnerBootstrapClient {
113104
tcp,
@@ -120,7 +111,6 @@ impl<N: Network> BootstrapClient<N> {
120111
http_client,
121112
latest_committee,
122113
dev,
123-
shutdown_tx,
124114
};
125115
let node = BootstrapClient(Arc::new(inner));
126116

@@ -133,9 +123,6 @@ impl<N: Network> BootstrapClient<N> {
133123
// Enable the TCP listener. Note: This must be called after the above protocols.
134124
node.tcp().enable_listener().await.expect("Failed to enable the TCP listener");
135125

136-
// Await the shutdown signal.
137-
let _ = shutdown_rx.await;
138-
139126
Ok(node)
140127
}
141128

@@ -227,11 +214,6 @@ impl<N: Network> BootstrapClient<N> {
227214

228215
// Shut down the low-level network features.
229216
self.tcp.shut_down().await;
230-
231-
// Shut down the node.
232-
if let Some(shutdown_tx) = self.shutdown_tx.lock().take() {
233-
let _ = shutdown_tx.send(());
234-
}
235217
}
236218

237219
/// Blocks until a shutdown signal was received or manual shutdown was triggered.

0 commit comments

Comments
 (0)