fix miner problem in that it wont listen to events
@@ -231,6 +231,9 @@ impl Miner {
true => task::spawn(self.mining()),
false => task::spawn(self.not_mining()),
};
+ // This flag will let the future select loop again if the miner has not been issued a shutdown command.
+ let mut wait_for_miner = false;
+ 'inner: while (!wait_for_miner) {
futures::select! {
msg = block_event.select_next_some() => {
match *msg {
@@ -240,6 +243,7 @@ impl Miner {
BlockAddResult::Ok | BlockAddResult::ChainReorg(_) => {
stop_mining_flag.store(true, Ordering::Relaxed);
start_mining = true;
+ wait_for_miner = true;
},
_ => {}
}
@@ -255,10 +259,12 @@ impl Miner {
info!(target: LOG_TARGET,
"Our chain has synchronised with the network, or is a seed node. Starting miner");
start_mining = true;
+ wait_for_miner = true;
},
FallenBehind(SyncStatus::Lagging(_, _)) => {
info!(target: LOG_TARGET, "Our chain has fallen behind the network. Pausing miner");
start_mining = false;
+ wait_for_miner = true;
},
_ => {},
}
@@ -269,6 +275,7 @@ impl Miner {
break 'main;
}
};
+ }
self = mining_future.await.expect("Miner crashed").expect("Miner crashed");
}
debug!(target: LOG_TARGET, "Mining thread stopped.");
