Skip to content

Commit

Permalink
fix unwrap on sv1-mining-device tcp connection..
Browse files Browse the repository at this point in the history
Update roles/test-utils/mining-device-sv1/src/client.rs

Co-authored-by: jbesraa <[email protected]>
  • Loading branch information
plebhash and jbesraa committed Dec 11, 2024
1 parent 6b105cf commit 3678bb1
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions roles/test-utils/mining-device-sv1/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,20 @@ impl Client {
task::spawn(async move {
let mut messages = BufReader::new(&*reader).lines();
while let Some(message) = messages.next().await {
let message = message.unwrap();
sender_incoming.send(message).await.unwrap();
match message {
Ok(msg) => {
if let Err(e) = sender_incoming.send(msg).await {
eprintln!("Failed to send message to receiver_incoming: {:?}", e);
break; // Exit the loop if sending fails
}
}
Err(e) => {
eprintln!("Error reading from socket: {:?}", e);
break; // Exit the loop on read failure
}
}
}
eprintln!("Reader task terminated.");
});

// Waits to receive a message from `sender_outgoing` and writes it to the socket for the
Expand Down

0 comments on commit 3678bb1

Please sign in to comment.