Skip to content

Commit

Permalink
fmt, clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnnyFFM committed Feb 19, 2019
1 parent 0bf40a4 commit 98372df
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ mod gpu_worker_async;
#[cfg(feature = "opencl")]
mod ocl;

use clap::{App, Arg};
use crate::config::load_cfg;
use crate::miner::Miner;
use clap::{App, Arg};
use std::process;

cfg_if! {
Expand Down
20 changes: 9 additions & 11 deletions src/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use futures::sync::mpsc;
#[cfg(feature = "opencl")]
use ocl_core::Mem;
use std::cell::RefCell;
use std::cmp::{min,max};
use std::cmp::{max, min};
use std::collections::HashMap;
use std::fs::read_dir;
use std::path::Path;
Expand Down Expand Up @@ -426,7 +426,7 @@ impl Miner {
cfg.account_id_to_secret_phrase,
cfg.timeout,
// ensure timeout < polling intervall
min(cfg.timeout,max(1000, cfg.get_mining_info_interval)-200),
min(cfg.timeout, max(1000, cfg.get_mining_info_interval) - 200),
core.handle(),
(total_size * 4 / 1024 / 1024) as usize,
cfg.send_proxy_details,
Expand Down Expand Up @@ -577,15 +577,13 @@ impl Miner {
state
.account_id_to_best_deadline
.insert(nonce_data.account_id, deadline);
inner_handle.spawn(
request_handler.submit_nonce(
nonce_data.account_id,
nonce_data.nonce,
nonce_data.height,
nonce_data.deadline,
deadline,
)
);
inner_handle.spawn(request_handler.submit_nonce(
nonce_data.account_id,
nonce_data.nonce,
nonce_data.height,
nonce_data.deadline,
deadline,
));
}

if nonce_data.reader_task_processed {
Expand Down
16 changes: 10 additions & 6 deletions src/requests.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use bytes::Buf;
use futures::future::Future;
use futures::{stream, future};
use futures::stream::Stream;
use futures::{future, stream};
use reqwest::header::HeaderName;
use reqwest::r#async::{Chunk, ClientBuilder, Decoder, Request};
use serde::de::{self, DeserializeOwned};
Expand Down Expand Up @@ -168,7 +168,11 @@ impl RequestHandler {

pub fn uri_for(&self, path: &str, query: &str) -> Url {
let mut url = self.base_uri.clone();
url.path_segments_mut().map_err(|_| "cannot be base").unwrap().pop_if_empty().push(path);
url.path_segments_mut()
.map_err(|_| "cannot be base")
.unwrap()
.pop_if_empty()
.push(path);
url.set_query(Some(query));
url
}
Expand Down Expand Up @@ -222,7 +226,7 @@ impl RequestHandler {
}
Err(FetchError::Pool(e)) => {
log_submission_not_accepted(
height, account_id, nonce, d, e.code, e.message,
height, account_id, nonce, d, e.code, &e.message,
);
Ok(true)
}
Expand Down Expand Up @@ -278,7 +282,7 @@ fn log_submission_not_accepted(
nonce: u64,
deadline: u64,
err_code: i32,
msg: String,
msg: &str,
) {
error!(
"submission not accepted: height={}, account={}, nonce={}, \
Expand All @@ -294,7 +298,7 @@ fn log_submission_accepted(account_id: u64, nonce: u64, deadline: u64) {
);
}

fn parse_json_result<T: DeserializeOwned>(body: Chunk) -> Result<T, PoolError> {
fn parse_json_result<T: DeserializeOwned>(body: &Chunk) -> Result<T, PoolError> {
match serde_json::from_slice(body.bytes()) {
Ok(x) => Ok(x),
_ => match serde_json::from_slice::<PoolErrorWrapper>(body.bytes()) {
Expand Down Expand Up @@ -329,7 +333,7 @@ fn do_req<T: DeserializeOwned>(
body.concat2()
})
.from_err::<FetchError>()
.and_then(|body| match parse_json_result(body) {
.and_then(|body| match parse_json_result(&body) {
Ok(x) => Ok(x),
Err(e) => Err(e.into()),
})
Expand Down

0 comments on commit 98372df

Please sign in to comment.