Fixes to deal with internet connection drop.
This commit is contained in:
Generated
+170
-312
File diff suppressed because it is too large
Load Diff
+19
-10
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "nyash_client"
|
||||
version = "0.2.0"
|
||||
version = "0.2.1"
|
||||
edition = "2024"
|
||||
build = "build.rs"
|
||||
|
||||
@@ -9,17 +9,26 @@ name = "nyash-client"
|
||||
path = "src/client.rs"
|
||||
|
||||
[dependencies]
|
||||
flate2 = "1.1.9"
|
||||
flate2 = "1"
|
||||
ocl = { version = "0.19" }
|
||||
prost = "0.14.3"
|
||||
serde = { version = "1.0.228", features = ["derive"] }
|
||||
serde_json = "1.0.149"
|
||||
tokio = { version = "1.50.0", features = ["rt", "macros", "signal"] }
|
||||
tonic = "0.14.5"
|
||||
tonic-prost = "0.14.5"
|
||||
prost = "0.14"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
tokio = { version = "1", features = ["rt", "macros", "signal"] }
|
||||
tonic = "0.14"
|
||||
tonic-prost = "0.14"
|
||||
|
||||
[build-dependencies]
|
||||
tonic-prost-build = "0.14.5"
|
||||
tonic-prost-build = "0.14"
|
||||
ocl-include = "0.6"
|
||||
flate2 = "1.1.9"
|
||||
flate2 = "1"
|
||||
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
debug = false
|
||||
incremental = false
|
||||
codegen-units = 1
|
||||
opt-level = 3
|
||||
strip = true
|
||||
|
||||
|
||||
+29
-14
@@ -161,8 +161,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
const OCL_NYAS_GZ_SRC: &[u8] =
|
||||
include_bytes!(concat!(env!("OUT_DIR"), "/nyash_aes_full.cl.gz"));
|
||||
|
||||
println!("********* Nyash client version 0.2.1 *********");
|
||||
|
||||
println!("OCL bin src lenght {}", OCL_NYAS_GZ_SRC.len());
|
||||
println!("Hello, world nya!");
|
||||
|
||||
//use ocl::{Buffer, Context, Device, Kernel, Platform, Program, Queue, flags};
|
||||
let (devices, mut app_conf) =
|
||||
client_config::get_devices_conf(CONF_RILE_NAME).expect("Error loading config!");
|
||||
@@ -228,7 +230,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.expect("Error setting target data!");
|
||||
|
||||
// Don't keep connection alive when idle
|
||||
let nya_channel: tonic::transport::Channel = tonic::transport::Endpoint::from_static(S_ADDR)
|
||||
let mut nya_channel: tonic::transport::Channel = tonic::transport::Endpoint::from_static(S_ADDR)
|
||||
.keep_alive_while_idle(false)
|
||||
.keep_alive_timeout(Duration::from_secs(10))
|
||||
.connect_timeout(Duration::from_secs(10))
|
||||
@@ -236,16 +238,19 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.await
|
||||
.expect("Error connecting to server!");
|
||||
|
||||
let key_found = match get_progress(nya_channel.clone()).await {
|
||||
Err(_) => {
|
||||
println!("Error getting progress!");
|
||||
false
|
||||
}
|
||||
Ok(p_r) => {
|
||||
println!("Current progress {:.8}%", p_r.progress * 100.0);
|
||||
p_r.key_found
|
||||
}
|
||||
};
|
||||
let p_r = get_progress(nya_channel.clone()).await?;
|
||||
println!("Current progress {:.8}%", p_r.progress * 100.0);
|
||||
let key_found = p_r.key_found;
|
||||
// let key_found = match get_progress(nya_channel.clone()).await {
|
||||
// Err(ex) => {
|
||||
// println!("Error getting progress!");
|
||||
// false
|
||||
// }
|
||||
// Ok(p_r) => {
|
||||
// println!("Current progress {:.8}%", p_r.progress * 100.0);
|
||||
// p_r.key_found
|
||||
// }
|
||||
// };
|
||||
|
||||
let mut giga_keys_per_second: f64 = 0f64;
|
||||
let req_work_size: u64 = nyash_dev_cfg.batch_size as u64 * nyash_dev_cfg.work_size as u64;
|
||||
@@ -262,10 +267,20 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
});
|
||||
|
||||
while *shared_key_found.read().await == false {
|
||||
let mut work = get_work(nya_channel.clone(), req_work_size).await;
|
||||
let mut work: Result<WorkReply, tonic::Status> = get_work(nya_channel.clone(), req_work_size).await;
|
||||
while work.is_err() {
|
||||
println!("Error getting work, waiting 10 seconds and trying again...");
|
||||
tokio::time::sleep(Duration::from_secs(10)).await;
|
||||
|
||||
// adding this to battle intenrnet changing IPs shinanigans.
|
||||
nya_channel = tonic::transport::Endpoint::from_static(S_ADDR)
|
||||
.keep_alive_while_idle(false)
|
||||
.keep_alive_timeout(Duration::from_secs(5))
|
||||
.connect_timeout(Duration::from_secs(5))
|
||||
.connect()
|
||||
.await
|
||||
.expect("Error connecting to server!");
|
||||
|
||||
work = get_work(nya_channel.clone(), req_work_size).await;
|
||||
}
|
||||
let work = work.expect("Error getting work!");
|
||||
@@ -335,7 +350,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
let resp = commit_work(nya_channel.clone(), w_k).await;
|
||||
match resp {
|
||||
Ok(c_r) => println!("Work commited. Progress: {:.8}%", c_r.progress * 100.0),
|
||||
Ok(c_r) => println!("Work commited. Progress: {:.13}%", c_r.progress * 100.0),
|
||||
Err(_) => println!("Error commiting work..."),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user