Skip to content

Commit

Permalink
parse url directly from config
Browse files Browse the repository at this point in the history
  • Loading branch information
bold committed Mar 3, 2019
1 parent 3554c5d commit 5b8a983
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ page_size = "0.4.1"
aligned_alloc = "0.1"
reqwest = { version = "0.9.9", default-features = false, features = ["rustls-tls"] }
bytes = "0.4.11"
url_serde = "0.2"

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = ["fileapi"] }
Expand Down
5 changes: 4 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
use std::collections::HashMap;
use std::fs;
use std::u32;
use url::Url;

#[derive(Debug, Serialize, Deserialize)]
pub struct Cfg {
#[serde(default = "default_secret_phrase")]
pub account_id_to_secret_phrase: HashMap<u64, String>,

pub plot_dirs: Vec<String>,
pub url: String,

#[serde(with = "url_serde")]
pub url: Url,

#[serde(default = "default_hdd_reader_thread_count")]
pub hdd_reader_thread_count: usize,
Expand Down
4 changes: 1 addition & 3 deletions src/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ use std::u64;
use stopwatch::Stopwatch;
use tokio::prelude::*;
use tokio::timer::Interval;
use url::Url;
use tokio::runtime::TaskExecutor;

pub struct Miner {
Expand Down Expand Up @@ -398,7 +397,6 @@ impl Miner {
let tx_read_replies_gpu = Some(tx_read_replies_gpu);
#[cfg(not(feature = "opencl"))]
let tx_read_replies_gpu = None;
let base_url = Url::parse(&cfg.url).expect("invalid mining server url");

Miner {
reader_task_count: drive_id_to_plots.len(),
Expand All @@ -419,7 +417,7 @@ impl Miner {
target_deadline: cfg.target_deadline,
account_id_to_target_deadline: cfg.account_id_to_target_deadline,
request_handler: RequestHandler::new(
base_url,
cfg.url,
cfg.account_id_to_secret_phrase,
cfg.timeout,
// ensure timeout < polling intervall
Expand Down

0 comments on commit 5b8a983

Please sign in to comment.