diff --git a/roles/Cargo.lock b/roles/Cargo.lock index fbaeadc6da..e20c6b9a22 100644 --- a/roles/Cargo.lock +++ b/roles/Cargo.lock @@ -1341,7 +1341,6 @@ version = "0.1.1" dependencies = [ "async-channel 1.9.0", "async-recursion 0.3.2", - "async-std", "binary_sv2", "buffer_sv2", "clap", @@ -1354,6 +1353,7 @@ dependencies = [ "roles_logic_sv2", "sha2 0.10.8", "stratum-common", + "tokio", "tracing", "tracing-subscriber", ] @@ -2053,7 +2053,7 @@ dependencies = [ [[package]] name = "sv1_api" -version = "1.0.0" +version = "1.0.1" dependencies = [ "binary_sv2", "bitcoin_hashes 0.3.2", diff --git a/roles/test-utils/mining-device/Cargo.toml b/roles/test-utils/mining-device/Cargo.toml index 4ce6c5037a..feedba02ef 100644 --- a/roles/test-utils/mining-device/Cargo.toml +++ b/roles/test-utils/mining-device/Cargo.toml @@ -12,9 +12,8 @@ codec_sv2 = { version = "^1.0.1", path = "../../../protocols/v2/codec-sv2", feat roles_logic_sv2 = { version = "1.0.0", path = "../../../protocols/v2/roles-logic-sv2" } const_sv2 = { version = "1.0.0", path = "../../../protocols/v2/const-sv2" } async-channel = "1.5.1" -async-std={version = "1.8.0", features = ["attributes"]} binary_sv2 = { version = "1.0.0", path = "../../../protocols/v2/binary-sv2/binary-sv2" } -network_helpers_sv2 = { version = "2.0.0", path = "../../roles-utils/network-helpers", features=["async_std"] } +network_helpers_sv2 = { version = "2.0.0", path = "../../roles-utils/network-helpers", features=["tokio"] } buffer_sv2 = { version = "1.0.0", path = "../../../utils/buffer"} async-recursion = "0.3.2" rand = "0.8.4" @@ -24,3 +23,4 @@ clap = { version = "^4.5.4", features = ["derive"] } tracing = { version = "0.1" } tracing-subscriber = "0.3" sha2 = "0.10.6" +tokio = "^1.36.0" diff --git a/roles/test-utils/mining-device/src/main.rs b/roles/test-utils/mining-device/src/main.rs index 1bfbf6737a..912775d0b6 100644 --- a/roles/test-utils/mining-device/src/main.rs +++ b/roles/test-utils/mining-device/src/main.rs @@ -1,10 +1,14 @@ -use async_std::net::TcpStream; use key_utils::Secp256k1PublicKey; -use network_helpers_sv2::Connection; +use network_helpers_sv2::noise_connection_tokio::Connection; use roles_logic_sv2::utils::Id; -use std::{net::SocketAddr, sync::Arc, thread::sleep, time::Duration}; +use std::{ + net::{SocketAddr, ToSocketAddrs}, + sync::Arc, + thread::sleep, + time::Duration, +}; +use tokio::net::TcpStream; -use async_std::net::ToSocketAddrs; use clap::Parser; use rand::{thread_rng, Rng}; use std::time::Instant; @@ -57,14 +61,12 @@ async fn connect( let address = address .clone() .to_socket_addrs() - .await .expect("Invalid pool address, use one of this formats: ip:port, domain:port") .next() .expect("Invalid pool address, use one of this formats: ip:port, domain:port"); info!("Connecting to pool at {}", address); let socket = loop { - let pool = - async_std::future::timeout(Duration::from_secs(5), TcpStream::connect(address)).await; + let pool = tokio::time::timeout(Duration::from_secs(5), TcpStream::connect(address)).await; match pool { Ok(result) => match result { Ok(socket) => break socket, @@ -85,15 +87,15 @@ async fn connect( info!("Pool tcp connection established at {}", address); let address = socket.peer_addr().unwrap(); let initiator = Initiator::new(pub_key.map(|e| e.0)); - let (receiver, sender): (Receiver, Sender) = - Connection::new(socket, codec_sv2::HandshakeRole::Initiator(initiator), 10) + let (receiver, sender, _, _): (Receiver, Sender, _, _) = + Connection::new(socket, codec_sv2::HandshakeRole::Initiator(initiator)) .await .unwrap(); info!("Pool noise connection established at {}", address); Device::start(receiver, sender, address, device_id, user_id, handicap).await } -#[async_std::main] +#[tokio::main] async fn main() { let args = Args::parse(); tracing_subscriber::fmt::init(); @@ -303,7 +305,7 @@ impl Device { .unwrap(); }); - async_std::task::spawn(async move { + tokio::task::spawn(async move { let recv = share_recv.clone(); loop { let (nonce, job_id, version, ntime) = recv.recv().await.unwrap();