Add logging to stop_tenure and stop_miner

Signed-off-by: Jacinta Ferrant <jacinta@trustmachines.co>
This commit is contained in:
Jacinta Ferrant
2024-03-08 12:43:08 -05:00
committed by Brice Dobry
parent bdfc3604b1
commit 79f0da4026
2 changed files with 9 additions and 2 deletions

View File

@@ -134,11 +134,16 @@ impl BlockMinerThread {
/// Stop a miner tenure by blocking the miner and then joining the tenure thread
pub fn stop_miner(globals: &Globals, prior_miner: JoinHandle<()>) {
let id = prior_miner.thread().id();
debug!("Blocking miner thread ID {:?}", id);
globals.block_miner();
debug!("Joining miner thread ID {:?}", id);
prior_miner
.join()
.expect("FATAL: IO failure joining prior mining thread");
debug!("Joined miner thread ID {:?}", id);
globals.unblock_miner();
debug!("Unblocked miner.");
}
pub fn run_miner(mut self, prior_miner: Option<JoinHandle<()>>) {

View File

@@ -596,7 +596,7 @@ impl RelayerThread {
error!("Relayer: Failed to start tenure thread: {:?}", &e);
NakamotoNodeError::SpawnError(e)
})?;
debug!("Relayer: started tenure thread ID {:?}", new_miner_handle.thread().id());
self.miner_thread.replace(new_miner_handle);
Ok(())
@@ -606,8 +606,10 @@ impl RelayerThread {
// when stopping a tenure, block the mining thread if its currently running, then join it.
// do this in a new thread will (so that the new thread stalls, not the relayer)
let Some(prior_tenure_thread) = self.miner_thread.take() else {
debug!("Relayer: no tenure thread to stop");
return Ok(());
};
let id = prior_tenure_thread.thread().id();
let globals = self.globals.clone();
let stop_handle = std::thread::Builder::new()
@@ -619,7 +621,7 @@ impl RelayerThread {
})?;
self.miner_thread.replace(stop_handle);
debug!("Relayer: stopped tenure thread ID {id:?}");
Ok(())
}