Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions neptune-core/src/main_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,11 @@ struct MainToMinerChannel(Option<mpsc::Sender<MainToMiner>>);

impl MainToMinerChannel {
/// Send a message to the miner task (if any).
fn send(&self, message: MainToMiner) {
// Do no use the async `send` function because it blocks until there
// is spare capacity on the channel. Messages to the miner are not
// critical so if there is no capacity left, just log an error
// message.
async fn send(&self, message: MainToMiner) {
if let Some(channel) = &self.0 {
if let Err(e) = channel.try_send(message) {
error!("Failed to send pause message to miner thread:\n{e}");
}
if channel.capacity() > 0 {
channel.send(message).await.err().into_iter().for_each(|e| {error!("Failed to send pause message to miner thread:\n{e}")})
} else {tracing::warn!("no capacity to send to the miner: {message}")}
}
}
}
Expand Down
Loading