Skip to content

Commit

Permalink
Suppress panicking when pipe closed
Browse files Browse the repository at this point in the history
  • Loading branch information
Guilherme Lawless committed May 17, 2019
1 parent d0be2bb commit e537acf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/gpu.rs
Expand Up @@ -39,7 +39,7 @@ impl Gpu {
.build()?;

let device = pro_que.device();
eprintln!(
println!(
"Initializing GPU: {} {}",
device.vendor().unwrap_or_else(|_| "[unknown]".into()),
device.name().unwrap_or_else(|_| "[unknown]".into())
Expand Down
10 changes: 6 additions & 4 deletions src/main.rs
Expand Up @@ -14,6 +14,7 @@ extern crate serde_json;

mod gpu;

use std::io::{self, Write};
use std::u64;
use std::num::Wrapping;
use std::collections::VecDeque;
Expand Down Expand Up @@ -274,9 +275,10 @@ impl RpcService {
Box::new(self.generate_work(root, difficulty).then(move |res| match res {
Ok(work) => {
let end = PreciseTime::now();
println!("work_generate completed in {}ms for difficulty {:#x}",
writeln!(io::stdout(), "work_generate completed in {}ms for difficulty {:#x}",
start.to(end).num_milliseconds(),
difficulty);
difficulty)
.unwrap_or(());
let result_difficulty = work_value(root, work);
Ok((
StatusCode::Ok,
Expand All @@ -302,12 +304,12 @@ impl RpcService {
}))
}
RpcCommand::WorkCancel(root) => {
println!("Received work_cancel");
writeln!(io::stdout(), "Received work_cancel").unwrap_or(());
self.cancel_work(root);
Box::new(Box::new(future::ok((StatusCode::Ok, json!({})))))
}
RpcCommand::WorkValidate(root, work, difficulty) => {
println!("Received work_validate");
writeln!(io::stdout(), "Received work_validate").unwrap_or(());
let (valid, result_difficulty) = work_valid(root, work, difficulty);
Box::new(future::ok((
StatusCode::Ok,
Expand Down

0 comments on commit e537acf

Please sign in to comment.