From 46e2c74a98baba5f158178e4991b79b6575fe073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20H=C3=A4ggblad?= Date: Mon, 20 Feb 2023 21:55:29 +0100 Subject: [PATCH] Rename crate to nym-task (#3064) * Rename to nym-task * Update imports to use nym_task * Update to nym_task in explicit module prefix * Touchups and rustfmt * rustfmt * crate metadata * fix nym-connect-android --- Cargo.lock | 50 +-- clients/client-core/Cargo.toml | 2 +- .../client-core/src/client/base_client/mod.rs | 2 +- .../src/client/cover_traffic_stream.rs | 2 +- clients/client-core/src/client/mix_traffic.rs | 2 +- .../acknowledgement_listener.rs | 2 +- .../action_controller.rs | 4 +- .../input_message_listener.rs | 2 +- .../acknowledgement_control/mod.rs | 2 +- .../retransmission_request_listener.rs | 2 +- .../sent_notification_listener.rs | 2 +- .../src/client/real_messages_control/mod.rs | 2 +- .../real_traffic_stream.rs | 4 +- .../client-core/src/client/received_buffer.rs | 6 +- .../client/replies/reply_controller/mod.rs | 2 +- .../src/client/replies/reply_storage/mod.rs | 2 +- .../src/client/topology_control.rs | 2 +- clients/native/Cargo.toml | 2 +- clients/native/src/client/mod.rs | 4 +- clients/native/src/websocket/handler.rs | 4 +- clients/native/src/websocket/listener.rs | 8 +- clients/socks5/Cargo.toml | 2 +- clients/socks5/src/client/mod.rs | 6 +- clients/socks5/src/socks/client.rs | 2 +- clients/socks5/src/socks/mixnet_responses.rs | 2 +- clients/socks5/src/socks/server.rs | 2 +- clients/webassembly/Cargo.toml | 2 +- clients/webassembly/src/client/mod.rs | 2 +- common/client-libs/gateway-client/Cargo.toml | 2 +- .../client-libs/gateway-client/src/client.rs | 2 +- .../gateway-client/src/packet_router.rs | 2 +- .../gateway-client/src/socket_state.rs | 2 +- common/client-libs/mixnet-client/Cargo.toml | 2 +- .../mixnet-client/src/forwarder.rs | 4 +- common/mixnode-common/Cargo.toml | 2 +- common/mixnode-common/src/verloc/listener.rs | 2 +- common/mixnode-common/src/verloc/mod.rs | 2 +- common/mixnode-common/src/verloc/sender.rs | 2 +- common/socks5/proxy-helpers/Cargo.toml | 2 +- .../src/connection_controller.rs | 2 +- .../proxy-helpers/src/proxy_runner/inbound.rs | 2 +- .../proxy-helpers/src/proxy_runner/mod.rs | 2 +- .../src/proxy_runner/outbound.rs | 2 +- common/task/Cargo.toml | 12 +- explorer-api/Cargo.toml | 2 +- .../src/country_statistics/distribution.rs | 2 +- .../src/country_statistics/geolocate.rs | 2 +- explorer-api/src/main.rs | 2 +- explorer-api/src/tasks.rs | 2 +- gateway/Cargo.toml | 2 +- .../connection_handler/authenticated.rs | 2 +- .../websocket/connection_handler/fresh.rs | 2 +- .../websocket/connection_handler/mod.rs | 2 +- .../client_handling/websocket/listener.rs | 4 +- .../receiver/connection_handler.rs | 2 +- .../node/mixnet_handling/receiver/listener.rs | 2 +- gateway/src/node/mod.rs | 2 +- mixnode/Cargo.toml | 2 +- mixnode/src/node/mod.rs | 2 +- mixnode/src/node/node_statistics.rs | 2 +- mixnode/src/node/packet_delayforwarder.rs | 2 +- nym-api/Cargo.toml | 2 +- .../circulating_supply_api/cache/refresher.rs | 2 +- nym-api/src/circulating_supply_api/mod.rs | 2 +- nym-api/src/coconut/dkg/controller.rs | 2 +- nym-api/src/epoch_operations/mod.rs | 2 +- nym-api/src/main.rs | 2 +- nym-api/src/network_monitor/mod.rs | 2 +- .../monitor/gateways_pinger.rs | 2 +- nym-api/src/network_monitor/monitor/mod.rs | 2 +- .../src/network_monitor/monitor/receiver.rs | 2 +- nym-api/src/network_monitor/monitor/sender.rs | 4 +- .../src/node_status_api/cache/refresher.rs | 2 +- nym-api/src/node_status_api/mod.rs | 2 +- nym-api/src/node_status_api/uptime_updater.rs | 2 +- .../src/nym_contract_cache/cache/refresher.rs | 2 +- nym-api/src/nym_contract_cache/mod.rs | 2 +- nym-connect-android/src-tauri/Cargo.lock | 349 +++++++++--------- nym-connect-android/src-tauri/Cargo.toml | 2 +- nym-connect-android/src-tauri/src/events.rs | 2 +- nym-connect-android/src-tauri/src/state.rs | 4 +- nym-connect-android/src-tauri/src/tasks.rs | 6 +- nym-connect/src-tauri/Cargo.toml | 2 +- nym-connect/src-tauri/src/events.rs | 2 +- nym-connect/src-tauri/src/state.rs | 6 +- nym-connect/src-tauri/src/tasks.rs | 6 +- sdk/rust/nym-sdk/Cargo.toml | 2 +- sdk/rust/nym-sdk/src/mixnet/client.rs | 2 +- .../network-requester/Cargo.toml | 2 +- .../network-requester/src/core.rs | 4 +- .../network-requester/src/socks5/tcp.rs | 2 +- 91 files changed, 319 insertions(+), 312 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d2cec6d7fd..025fcd5e88 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -710,13 +710,13 @@ dependencies = [ "nym-crypto", "nym-pemstore", "nym-sphinx", + "nym-task", "nym-topology", "rand 0.7.3", "serde", "serde_json", "sqlx 0.6.2", "tap", - "task", "tempfile", "thiserror", "time 0.3.17", @@ -1861,6 +1861,7 @@ dependencies = [ "network-defaults", "nym-contracts-common", "nym-mixnet-contract-common", + "nym-task", "okapi", "pretty_env_logger", "rand 0.8.5", @@ -1873,7 +1874,6 @@ dependencies = [ "schemars", "serde", "serde_json", - "task", "thiserror", "tokio", "validator-client", @@ -2129,9 +2129,9 @@ dependencies = [ "nym-crypto", "nym-pemstore", "nym-sphinx", + "nym-task", "rand 0.7.3", "serde", - "task", "thiserror", "tokio", "tokio-stream", @@ -3173,7 +3173,7 @@ dependencies = [ "futures", "log", "nym-sphinx", - "task", + "nym-task", "tokio", "tokio-util", ] @@ -3194,10 +3194,10 @@ dependencies = [ "nym-sphinx-framing", "nym-sphinx-params", "nym-sphinx-types", + "nym-task", "nym-version-checker", "rand 0.8.5", "serde", - "task", "thiserror", "tokio", "tokio-util", @@ -3406,6 +3406,7 @@ dependencies = [ "nym-mixnet-contract-common", "nym-pemstore", "nym-sphinx", + "nym-task", "nym-topology", "nym-version-checker", "nym-vesting-contract-common", @@ -3424,7 +3425,6 @@ dependencies = [ "serde_json", "sqlx 0.6.2", "tap", - "task", "thiserror", "time 0.3.17", "tokio", @@ -3546,6 +3546,7 @@ dependencies = [ "nym-crypto", "nym-pemstore", "nym-sphinx", + "nym-task", "nym-topology", "nym-version-checker", "pretty_env_logger", @@ -3553,7 +3554,6 @@ dependencies = [ "serde", "serde_json", "tap", - "task", "thiserror", "tokio", "tokio-tungstenite 0.14.0", @@ -3632,6 +3632,7 @@ dependencies = [ "nym-crypto", "nym-pemstore", "nym-sphinx", + "nym-task", "nym-types", "nym-version-checker", "once_cell", @@ -3642,7 +3643,6 @@ dependencies = [ "sqlx 0.5.13", "statistics-common", "subtle-encoding", - "task", "thiserror", "tokio", "tokio-stream", @@ -3699,6 +3699,7 @@ dependencies = [ "nym-sphinx", "nym-sphinx-params", "nym-sphinx-types", + "nym-task", "nym-topology", "nym-types", "nym-version-checker", @@ -3708,7 +3709,6 @@ dependencies = [ "serde", "serde_json", "sysinfo", - "task", "tokio", "tokio-util", "toml", @@ -3737,6 +3737,7 @@ dependencies = [ "nym-crypto", "nym-sdk", "nym-sphinx", + "nym-task", "nym-version-checker", "ordered-buffer", "pretty_env_logger", @@ -3750,7 +3751,6 @@ dependencies = [ "sqlx 0.6.2", "statistics-common", "tap", - "task", "thiserror", "tokio", "tokio-tungstenite 0.17.2", @@ -3811,10 +3811,10 @@ dependencies = [ "network-defaults", "nym-crypto", "nym-sphinx", + "nym-task", "pretty_env_logger", "rand 0.7.3", "tap", - "task", "thiserror", "tokio", "toml", @@ -3847,6 +3847,7 @@ dependencies = [ "nym-crypto", "nym-pemstore", "nym-sphinx", + "nym-task", "nym-topology", "nym-version-checker", "ordered-buffer", @@ -3859,7 +3860,6 @@ dependencies = [ "service-providers-common", "socks5-requests", "tap", - "task", "thiserror", "tokio", "url", @@ -3993,6 +3993,18 @@ dependencies = [ "sphinx", ] +[[package]] +name = "nym-task" +version = "0.1.0" +dependencies = [ + "futures", + "log", + "thiserror", + "tokio", + "wasm-bindgen", + "wasm-bindgen-futures", +] + [[package]] name = "nym-topology" version = "0.1.0" @@ -4640,9 +4652,9 @@ dependencies = [ "client-connections", "futures", "log", + "nym-task", "ordered-buffer", "socks5-requests", - "task", "tokio", "tokio-test", "tokio-util", @@ -6151,18 +6163,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" -[[package]] -name = "task" -version = "0.1.0" -dependencies = [ - "futures", - "log", - "thiserror", - "tokio", - "wasm-bindgen", - "wasm-bindgen-futures", -] - [[package]] name = "tempfile" version = "3.3.0" diff --git a/clients/client-core/Cargo.toml b/clients/client-core/Cargo.toml index 8c6ebb514d..b1cbb77c2a 100644 --- a/clients/client-core/Cargo.toml +++ b/clients/client-core/Cargo.toml @@ -35,7 +35,7 @@ nym-sphinx = { path = "../../common/nymsphinx" } nym-pemstore = { path = "../../common/pemstore" } nym-topology = { path = "../../common/topology" } validator-client = { path = "../../common/client-libs/validator-client", default-features = false } -task = { path = "../../common/task" } +nym-task = { path = "../../common/task" } [target."cfg(not(target_arch = \"wasm32\"))".dependencies.tokio-stream] version = "0.1.11" diff --git a/clients/client-core/src/client/base_client/mod.rs b/clients/client-core/src/client/base_client/mod.rs index b4f9ffeea9..52b45a4e17 100644 --- a/clients/client-core/src/client/base_client/mod.rs +++ b/clients/client-core/src/client/base_client/mod.rs @@ -36,10 +36,10 @@ use nym_sphinx::acknowledgements::AckKey; use nym_sphinx::addressing::clients::Recipient; use nym_sphinx::addressing::nodes::NodeIdentity; use nym_sphinx::receiver::ReconstructedMessage; +use nym_task::{TaskClient, TaskManager}; use std::sync::Arc; use std::time::Duration; use tap::TapFallible; -use task::{TaskClient, TaskManager}; use url::Url; #[cfg(not(target_arch = "wasm32"))] use validator_client::nyxd::CosmWasmClient; diff --git a/clients/client-core/src/client/cover_traffic_stream.rs b/clients/client-core/src/client/cover_traffic_stream.rs index e6cef250e5..eeb0652bf5 100644 --- a/clients/client-core/src/client/cover_traffic_stream.rs +++ b/clients/client-core/src/client/cover_traffic_stream.rs @@ -213,7 +213,7 @@ impl LoopCoverTrafficStream { tokio::task::yield_now().await; } - pub fn start_with_shutdown(mut self, mut shutdown: task::TaskClient) { + pub fn start_with_shutdown(mut self, mut shutdown: nym_task::TaskClient) { // we should set initial delay only when we actually start the stream let sampled = sample_poisson_duration(&mut self.rng, self.average_cover_message_sending_delay); diff --git a/clients/client-core/src/client/mix_traffic.rs b/clients/client-core/src/client/mix_traffic.rs index afade091f9..e4b5024d62 100644 --- a/clients/client-core/src/client/mix_traffic.rs +++ b/clients/client-core/src/client/mix_traffic.rs @@ -76,7 +76,7 @@ where } } - pub fn start_with_shutdown(mut self, mut shutdown: task::TaskClient) { + pub fn start_with_shutdown(mut self, mut shutdown: nym_task::TaskClient) { spawn_future(async move { debug!("Started MixTrafficController with graceful shutdown support"); diff --git a/clients/client-core/src/client/real_messages_control/acknowledgement_control/acknowledgement_listener.rs b/clients/client-core/src/client/real_messages_control/acknowledgement_control/acknowledgement_listener.rs index ab1603e09c..2be5f58f41 100644 --- a/clients/client-core/src/client/real_messages_control/acknowledgement_control/acknowledgement_listener.rs +++ b/clients/client-core/src/client/real_messages_control/acknowledgement_control/acknowledgement_listener.rs @@ -65,7 +65,7 @@ impl AcknowledgementListener { } } - pub(super) async fn run_with_shutdown(&mut self, mut shutdown: task::TaskClient) { + pub(super) async fn run_with_shutdown(&mut self, mut shutdown: nym_task::TaskClient) { debug!("Started AcknowledgementListener with graceful shutdown support"); while !shutdown.is_shutdown() { diff --git a/clients/client-core/src/client/real_messages_control/acknowledgement_control/action_controller.rs b/clients/client-core/src/client/real_messages_control/acknowledgement_control/action_controller.rs index f2656e060d..a812c90b92 100644 --- a/clients/client-core/src/client/real_messages_control/acknowledgement_control/action_controller.rs +++ b/clients/client-core/src/client/real_messages_control/acknowledgement_control/action_controller.rs @@ -216,7 +216,7 @@ impl ActionController { fn handle_expired_ack_timer( &mut self, expired_ack: Expired, - task_client: &mut task::TaskClient, + task_client: &mut nym_task::TaskClient, ) { // I'm honestly not sure how to handle it, because getting it means other things in our // system are already misbehaving. If we ever see this panic, then I guess we should worry @@ -260,7 +260,7 @@ impl ActionController { } } - pub(super) async fn run_with_shutdown(&mut self, mut shutdown: task::TaskClient) { + pub(super) async fn run_with_shutdown(&mut self, mut shutdown: nym_task::TaskClient) { debug!("Started ActionController with graceful shutdown support"); while !shutdown.is_shutdown() { diff --git a/clients/client-core/src/client/real_messages_control/acknowledgement_control/input_message_listener.rs b/clients/client-core/src/client/real_messages_control/acknowledgement_control/input_message_listener.rs index c537755da7..85d73fa304 100644 --- a/clients/client-core/src/client/real_messages_control/acknowledgement_control/input_message_listener.rs +++ b/clients/client-core/src/client/real_messages_control/acknowledgement_control/input_message_listener.rs @@ -109,7 +109,7 @@ where }; } - pub(super) async fn run_with_shutdown(&mut self, mut shutdown: task::TaskClient) { + pub(super) async fn run_with_shutdown(&mut self, mut shutdown: nym_task::TaskClient) { debug!("Started InputMessageListener with graceful shutdown support"); while !shutdown.is_shutdown() { diff --git a/clients/client-core/src/client/real_messages_control/acknowledgement_control/mod.rs b/clients/client-core/src/client/real_messages_control/acknowledgement_control/mod.rs index eaaacc8b74..ba8a5b9c54 100644 --- a/clients/client-core/src/client/real_messages_control/acknowledgement_control/mod.rs +++ b/clients/client-core/src/client/real_messages_control/acknowledgement_control/mod.rs @@ -249,7 +249,7 @@ where } } - pub(super) fn start_with_shutdown(self, shutdown: task::TaskClient) { + pub(super) fn start_with_shutdown(self, shutdown: nym_task::TaskClient) { let mut acknowledgement_listener = self.acknowledgement_listener; let mut input_message_listener = self.input_message_listener; let mut retransmission_request_listener = self.retransmission_request_listener; diff --git a/clients/client-core/src/client/real_messages_control/acknowledgement_control/retransmission_request_listener.rs b/clients/client-core/src/client/real_messages_control/acknowledgement_control/retransmission_request_listener.rs index eb05a29b47..45072dc2f3 100644 --- a/clients/client-core/src/client/real_messages_control/acknowledgement_control/retransmission_request_listener.rs +++ b/clients/client-core/src/client/real_messages_control/acknowledgement_control/retransmission_request_listener.rs @@ -137,7 +137,7 @@ where .await } - pub(super) async fn run_with_shutdown(&mut self, mut shutdown: task::TaskClient) { + pub(super) async fn run_with_shutdown(&mut self, mut shutdown: nym_task::TaskClient) { debug!("Started RetransmissionRequestListener with graceful shutdown support"); while !shutdown.is_shutdown() { diff --git a/clients/client-core/src/client/real_messages_control/acknowledgement_control/sent_notification_listener.rs b/clients/client-core/src/client/real_messages_control/acknowledgement_control/sent_notification_listener.rs index 3e827b6b4f..4d2445f162 100644 --- a/clients/client-core/src/client/real_messages_control/acknowledgement_control/sent_notification_listener.rs +++ b/clients/client-core/src/client/real_messages_control/acknowledgement_control/sent_notification_listener.rs @@ -37,7 +37,7 @@ impl SentNotificationListener { .unwrap(); } - pub(super) async fn run_with_shutdown(&mut self, mut shutdown: task::TaskClient) { + pub(super) async fn run_with_shutdown(&mut self, mut shutdown: nym_task::TaskClient) { debug!("Started SentNotificationListener with graceful shutdown support"); while !shutdown.is_shutdown() { diff --git a/clients/client-core/src/client/real_messages_control/mod.rs b/clients/client-core/src/client/real_messages_control/mod.rs index 158138b525..bb40312aa9 100644 --- a/clients/client-core/src/client/real_messages_control/mod.rs +++ b/clients/client-core/src/client/real_messages_control/mod.rs @@ -270,7 +270,7 @@ impl RealMessagesController { } } - pub fn start_with_shutdown(self, shutdown: task::TaskClient) { + pub fn start_with_shutdown(self, shutdown: nym_task::TaskClient) { let mut out_queue_control = self.out_queue_control; let ack_control = self.ack_control; let mut reply_control = self.reply_control; diff --git a/clients/client-core/src/client/real_messages_control/real_traffic_stream.rs b/clients/client-core/src/client/real_messages_control/real_traffic_stream.rs index 333d5f0fbc..650a77870a 100644 --- a/clients/client-core/src/client/real_messages_control/real_traffic_stream.rs +++ b/clients/client-core/src/client/real_messages_control/real_traffic_stream.rs @@ -460,7 +460,7 @@ where } #[cfg(not(target_arch = "wasm32"))] - fn log_status(&self, shutdown: &mut task::TaskClient) { + fn log_status(&self, shutdown: &mut nym_task::TaskClient) { use crate::error::ClientCoreStatusMessage; let packets = self.transmission_buffer.total_size(); @@ -501,7 +501,7 @@ where } } - pub(super) async fn run_with_shutdown(&mut self, mut shutdown: task::TaskClient) { + pub(super) async fn run_with_shutdown(&mut self, mut shutdown: nym_task::TaskClient) { debug!("Started OutQueueControl with graceful shutdown support"); #[cfg(not(target_arch = "wasm32"))] diff --git a/clients/client-core/src/client/received_buffer.rs b/clients/client-core/src/client/received_buffer.rs index 4ff19d1552..7d7ffdb021 100644 --- a/clients/client-core/src/client/received_buffer.rs +++ b/clients/client-core/src/client/received_buffer.rs @@ -399,7 +399,7 @@ impl RequestReceiver { } } - async fn run_with_shutdown(&mut self, mut shutdown: task::TaskClient) { + async fn run_with_shutdown(&mut self, mut shutdown: nym_task::TaskClient) { debug!("Started RequestReceiver with graceful shutdown support"); while !shutdown.is_shutdown() { tokio::select! { @@ -438,7 +438,7 @@ impl FragmentedMessageReceiver { } } - async fn run_with_shutdown(&mut self, mut shutdown: task::TaskClient) { + async fn run_with_shutdown(&mut self, mut shutdown: nym_task::TaskClient) { debug!("Started FragmentedMessageReceiver with graceful shutdown support"); while !shutdown.is_shutdown() { tokio::select! { @@ -488,7 +488,7 @@ impl ReceivedMessagesBufferController { } } - pub fn start_with_shutdown(self, shutdown: task::TaskClient) { + pub fn start_with_shutdown(self, shutdown: nym_task::TaskClient) { let mut fragmented_message_receiver = self.fragmented_message_receiver; let mut request_receiver = self.request_receiver; diff --git a/clients/client-core/src/client/replies/reply_controller/mod.rs b/clients/client-core/src/client/replies/reply_controller/mod.rs index 429f07dbf3..7df94c08c7 100644 --- a/clients/client-core/src/client/replies/reply_controller/mod.rs +++ b/clients/client-core/src/client/replies/reply_controller/mod.rs @@ -835,7 +835,7 @@ where // todo!() // } - pub(crate) async fn run_with_shutdown(&mut self, mut shutdown: task::TaskClient) { + pub(crate) async fn run_with_shutdown(&mut self, mut shutdown: nym_task::TaskClient) { debug!("Started ReplyController with graceful shutdown support"); let polling_rate = Duration::from_secs(5); diff --git a/clients/client-core/src/client/replies/reply_storage/mod.rs b/clients/client-core/src/client/replies/reply_storage/mod.rs index c74ad2bb6b..5b8c7b9dee 100644 --- a/clients/client-core/src/client/replies/reply_storage/mod.rs +++ b/clients/client-core/src/client/replies/reply_storage/mod.rs @@ -37,7 +37,7 @@ where pub async fn flush_on_shutdown( mut self, mem_state: CombinedReplyStorage, - mut shutdown: task::TaskClient, + mut shutdown: nym_task::TaskClient, ) { use log::{debug, error, info, warn}; diff --git a/clients/client-core/src/client/topology_control.rs b/clients/client-core/src/client/topology_control.rs index e10aafbf29..e94340f074 100644 --- a/clients/client-core/src/client/topology_control.rs +++ b/clients/client-core/src/client/topology_control.rs @@ -306,7 +306,7 @@ impl TopologyRefresher { self.topology_accessor.ensure_is_routable().await } - pub fn start_with_shutdown(mut self, mut shutdown: task::TaskClient) { + pub fn start_with_shutdown(mut self, mut shutdown: nym_task::TaskClient) { spawn_future(async move { debug!("Started TopologyRefresher with graceful shutdown support"); diff --git a/clients/native/Cargo.toml b/clients/native/Cargo.toml index 562ff9e469..c101e4bcf8 100644 --- a/clients/native/Cargo.toml +++ b/clients/native/Cargo.toml @@ -49,7 +49,7 @@ gateway-requests = { path = "../../gateway/gateway-requests" } network-defaults = { path = "../../common/network-defaults" } nym-sphinx = { path = "../../common/nymsphinx" } nym-pemstore = { path = "../../common/pemstore" } -task = { path = "../../common/task" } +nym-task = { path = "../../common/task" } nym-topology = { path = "../../common/topology" } validator-client = { path = "../../common/client-libs/validator-client", features = ["nyxd-client"] } nym-version-checker = { path = "../../common/version-checker" } diff --git a/clients/native/src/client/mod.rs b/clients/native/src/client/mod.rs index a16fbde944..ddd6ea0ce2 100644 --- a/clients/native/src/client/mod.rs +++ b/clients/native/src/client/mod.rs @@ -19,7 +19,7 @@ use futures::channel::mpsc; use gateway_client::bandwidth::BandwidthController; use log::*; use nym_sphinx::anonymous_replies::requests::AnonymousSenderTag; -use task::TaskManager; +use nym_task::TaskManager; use tokio::sync::watch::error::SendError; use validator_client::nyxd::QueryNyxdClient; @@ -85,7 +85,7 @@ impl SocketClient { client_output: ClientOutput, client_state: ClientState, self_address: &Recipient, - shutdown: task::TaskClient, + shutdown: nym_task::TaskClient, ) { info!("Starting websocket listener..."); diff --git a/clients/native/src/websocket/handler.rs b/clients/native/src/websocket/handler.rs index fff50b77b9..753d2c4386 100644 --- a/clients/native/src/websocket/handler.rs +++ b/clients/native/src/websocket/handler.rs @@ -357,7 +357,7 @@ impl Handler { async fn listen_for_requests( &mut self, mut msg_receiver: ReconstructedMessagesReceiver, - mut task_client: task::TaskClient, + mut task_client: nym_task::TaskClient, ) { while !task_client.is_shutdown() { tokio::select! { @@ -410,7 +410,7 @@ impl Handler { pub(crate) async fn handle_connection( mut self, socket: TcpStream, - mut task_client: task::TaskClient, + mut task_client: nym_task::TaskClient, ) { // We don't want a crash in the connection handler to trigger a shutdown of the whole // process. diff --git a/clients/native/src/websocket/listener.rs b/clients/native/src/websocket/listener.rs index 534fd2dafc..712389145a 100644 --- a/clients/native/src/websocket/listener.rs +++ b/clients/native/src/websocket/listener.rs @@ -32,7 +32,11 @@ impl Listener { } } - pub(crate) async fn run(&mut self, handler: HandlerBuilder, mut task_client: task::TaskClient) { + pub(crate) async fn run( + &mut self, + handler: HandlerBuilder, + mut task_client: nym_task::TaskClient, + ) { let tcp_listener = match tokio::net::TcpListener::bind(self.address).await { Ok(listener) => listener, Err(err) => { @@ -103,7 +107,7 @@ impl Listener { pub(crate) fn start( mut self, handler: HandlerBuilder, - shutdown: task::TaskClient, + shutdown: nym_task::TaskClient, ) -> JoinHandle<()> { info!("Running websocket on {:?}", self.address.to_string()); diff --git a/clients/socks5/Cargo.toml b/clients/socks5/Cargo.toml index 2cd17e6a4f..51e33b97ce 100644 --- a/clients/socks5/Cargo.toml +++ b/clients/socks5/Cargo.toml @@ -47,7 +47,7 @@ nym-pemstore = { path = "../../common/pemstore" } proxy-helpers = { path = "../../common/socks5/proxy-helpers" } service-providers-common = { path = "../../service-providers/common" } socks5-requests = { path = "../../common/socks5/requests" } -task = { path = "../../common/task" } +nym-task = { path = "../../common/task" } nym-topology = { path = "../../common/topology" } validator-client = { path = "../../common/client-libs/validator-client", features = ["nyxd-client"] } nym-version-checker = { path = "../../common/version-checker" } diff --git a/clients/socks5/src/client/mod.rs b/clients/socks5/src/client/mod.rs index 3354bab401..ae50726184 100644 --- a/clients/socks5/src/client/mod.rs +++ b/clients/socks5/src/client/mod.rs @@ -22,8 +22,8 @@ use futures::StreamExt; use gateway_client::bandwidth::BandwidthController; use log::*; use nym_sphinx::addressing::clients::Recipient; +use nym_task::{TaskClient, TaskManager}; use std::error::Error; -use task::{TaskClient, TaskManager}; use validator_client::nyxd::QueryNyxdClient; pub mod config; @@ -142,7 +142,7 @@ impl NymClient { ), shutdown.clone(), ); - task::spawn_with_report_error( + nym_task::spawn_with_report_error( async move { sphinx_socks .serve( @@ -169,7 +169,7 @@ impl NymClient { pub async fn run_and_listen( self, mut receiver: Socks5ControlMessageReceiver, - sender: task::StatusSender, + sender: nym_task::StatusSender, ) -> Result<(), Box> { // Start the main task let mut shutdown = self.start().await?; diff --git a/clients/socks5/src/socks/client.rs b/clients/socks5/src/socks/client.rs index 75f5fada7c..15dc64a513 100644 --- a/clients/socks5/src/socks/client.rs +++ b/clients/socks5/src/socks/client.rs @@ -10,6 +10,7 @@ use futures::channel::mpsc; use futures::task::{Context, Poll}; use log::*; use nym_sphinx::addressing::clients::Recipient; +use nym_task::TaskClient; use pin_project::pin_project; use proxy_helpers::connection_controller::{ ConnectionReceiver, ControllerCommand, ControllerSender, @@ -23,7 +24,6 @@ use socks5_requests::{ use std::io; use std::net::SocketAddr; use std::pin::Pin; -use task::TaskClient; use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, ReadBuf}; use tokio::{self, net::TcpStream}; diff --git a/clients/socks5/src/socks/mixnet_responses.rs b/clients/socks5/src/socks/mixnet_responses.rs index 2c46bc3f6f..e905cd2d84 100644 --- a/clients/socks5/src/socks/mixnet_responses.rs +++ b/clients/socks5/src/socks/mixnet_responses.rs @@ -5,10 +5,10 @@ use log::*; use client_core::client::received_buffer::ReconstructedMessagesReceiver; use client_core::client::received_buffer::{ReceivedBufferMessage, ReceivedBufferRequestSender}; use nym_sphinx::receiver::ReconstructedMessage; +use nym_task::TaskClient; use proxy_helpers::connection_controller::ControllerSender; use service_providers_common::interface::{ControlResponse, ResponseContent}; use socks5_requests::{Socks5ProviderResponse, Socks5Response, Socks5ResponseContent}; -use task::TaskClient; use crate::error::Socks5ClientError; diff --git a/clients/socks5/src/socks/server.rs b/clients/socks5/src/socks/server.rs index 5b376b1110..23ace2e198 100644 --- a/clients/socks5/src/socks/server.rs +++ b/clients/socks5/src/socks/server.rs @@ -10,10 +10,10 @@ use client_core::client::{ }; use log::*; use nym_sphinx::addressing::clients::Recipient; +use nym_task::TaskClient; use proxy_helpers::connection_controller::Controller; use std::net::SocketAddr; use tap::TapFallible; -use task::TaskClient; use tokio::net::TcpListener; /// A Socks5 server that listens for connections. diff --git a/clients/webassembly/Cargo.toml b/clients/webassembly/Cargo.toml index 2510a41f4a..430dc7a7d3 100644 --- a/clients/webassembly/Cargo.toml +++ b/clients/webassembly/Cargo.toml @@ -39,7 +39,7 @@ nym-sphinx = { path = "../../common/nymsphinx" } gateway-client = { path = "../../common/client-libs/gateway-client", default-features = false, features = ["wasm"] } validator-client = { path = "../../common/client-libs/validator-client", default-features = false } wasm-utils = { path = "../../common/wasm-utils" } -task = { path = "../../common/task" } +nym-task = { path = "../../common/task" } # The `console_error_panic_hook` crate provides better debugging of panics by # logging them with `console.error`. This is great for development, but requires # all the `std::fmt` and `std::panicking` infrastructure, so isn't great for diff --git a/clients/webassembly/src/client/mod.rs b/clients/webassembly/src/client/mod.rs index 269dfee52d..34ec4a9396 100644 --- a/clients/webassembly/src/client/mod.rs +++ b/clients/webassembly/src/client/mod.rs @@ -15,9 +15,9 @@ use gateway_client::wasm_mockups::SigningNyxdClient; use js_sys::Promise; use nym_sphinx::addressing::clients::Recipient; use nym_sphinx::anonymous_replies::requests::AnonymousSenderTag; +use nym_task::TaskManager; use rand::rngs::OsRng; use std::sync::Arc; -use task::TaskManager; use wasm_bindgen::prelude::*; use wasm_bindgen_futures::future_to_promise; use wasm_utils::{console_error, console_log}; diff --git a/common/client-libs/gateway-client/Cargo.toml b/common/client-libs/gateway-client/Cargo.toml index 2be6ef78e1..1924f94dba 100644 --- a/common/client-libs/gateway-client/Cargo.toml +++ b/common/client-libs/gateway-client/Cargo.toml @@ -26,7 +26,7 @@ network-defaults = { path = "../../network-defaults" } nym-sphinx = { path = "../../nymsphinx" } nym-pemstore = { path = "../../pemstore" } validator-client = { path = "../validator-client" } -task = { path = "../../task" } +nym-task = { path = "../../task" } serde = { version = "1.0", features = ["derive"]} mobile-storage = { path = "../../mobile-storage" } diff --git a/common/client-libs/gateway-client/src/client.rs b/common/client-libs/gateway-client/src/client.rs index 50253a706e..aa16a0667e 100644 --- a/common/client-libs/gateway-client/src/client.rs +++ b/common/client-libs/gateway-client/src/client.rs @@ -19,11 +19,11 @@ use log::*; use network_defaults::{REMAINING_BANDWIDTH_THRESHOLD, TOKENS_TO_BURN}; use nym_crypto::asymmetric::identity; use nym_sphinx::forwarding::packet::MixPacket; +use nym_task::TaskClient; use rand::rngs::OsRng; use std::convert::TryFrom; use std::sync::Arc; use std::time::Duration; -use task::TaskClient; use tungstenite::protocol::Message; #[cfg(not(target_arch = "wasm32"))] diff --git a/common/client-libs/gateway-client/src/packet_router.rs b/common/client-libs/gateway-client/src/packet_router.rs index 10877b29f7..c758abcc19 100644 --- a/common/client-libs/gateway-client/src/packet_router.rs +++ b/common/client-libs/gateway-client/src/packet_router.rs @@ -9,7 +9,7 @@ use futures::channel::mpsc; use log::*; use nym_sphinx::addressing::nodes::MAX_NODE_ADDRESS_UNPADDED_LEN; use nym_sphinx::params::packet_sizes::PacketSize; -use task::TaskClient; +use nym_task::TaskClient; pub type MixnetMessageSender = mpsc::UnboundedSender>>; pub type MixnetMessageReceiver = mpsc::UnboundedReceiver>>; diff --git a/common/client-libs/gateway-client/src/socket_state.rs b/common/client-libs/gateway-client/src/socket_state.rs index 2bedf1e8ed..007a1b1313 100644 --- a/common/client-libs/gateway-client/src/socket_state.rs +++ b/common/client-libs/gateway-client/src/socket_state.rs @@ -9,8 +9,8 @@ use futures::stream::{SplitSink, SplitStream}; use futures::{SinkExt, StreamExt}; use gateway_requests::registration::handshake::SharedKeys; use log::*; +use nym_task::TaskClient; use std::sync::Arc; -use task::TaskClient; use tungstenite::Message; #[cfg(not(target_arch = "wasm32"))] diff --git a/common/client-libs/mixnet-client/Cargo.toml b/common/client-libs/mixnet-client/Cargo.toml index 03a40ec356..f9763d626a 100644 --- a/common/client-libs/mixnet-client/Cargo.toml +++ b/common/client-libs/mixnet-client/Cargo.toml @@ -14,4 +14,4 @@ tokio-util = { version = "0.7.4", features = ["codec"] } # internal nym-sphinx = { path = "../../nymsphinx" } -task = { path = "../../task" } +nym-task = { path = "../../task" } diff --git a/common/client-libs/mixnet-client/src/forwarder.rs b/common/client-libs/mixnet-client/src/forwarder.rs index 974ee1947b..cefae1fc30 100644 --- a/common/client-libs/mixnet-client/src/forwarder.rs +++ b/common/client-libs/mixnet-client/src/forwarder.rs @@ -16,7 +16,7 @@ type MixForwardingReceiver = mpsc::UnboundedReceiver; pub struct PacketForwarder { mixnet_client: Client, packet_receiver: MixForwardingReceiver, - shutdown: task::TaskClient, + shutdown: nym_task::TaskClient, } impl PacketForwarder { @@ -26,7 +26,7 @@ impl PacketForwarder { initial_connection_timeout: Duration, maximum_connection_buffer_size: usize, use_legacy_version: bool, - shutdown: task::TaskClient, + shutdown: nym_task::TaskClient, ) -> (PacketForwarder, MixForwardingSender) { let client_config = Config::new( initial_reconnection_backoff, diff --git a/common/mixnode-common/Cargo.toml b/common/mixnode-common/Cargo.toml index 5156013848..e6bfbc764a 100644 --- a/common/mixnode-common/Cargo.toml +++ b/common/mixnode-common/Cargo.toml @@ -26,6 +26,6 @@ nym-sphinx-forwarding = { path = "../nymsphinx/forwarding" } nym-sphinx-framing = { path = "../nymsphinx/framing" } nym-sphinx-params = { path = "../nymsphinx/params" } nym-sphinx-types = { path = "../nymsphinx/types" } -task = { path = "../task" } +nym-task = { path = "../task" } validator-client = { path = "../client-libs/validator-client", features = ["nyxd-client"]} nym-version-checker = { path = "../version-checker" } diff --git a/common/mixnode-common/src/verloc/listener.rs b/common/mixnode-common/src/verloc/listener.rs index 4324a0712c..a41e4edc8f 100644 --- a/common/mixnode-common/src/verloc/listener.rs +++ b/common/mixnode-common/src/verloc/listener.rs @@ -7,11 +7,11 @@ use bytes::{BufMut, BytesMut}; use futures::StreamExt; use log::*; use nym_crypto::asymmetric::identity; +use nym_task::TaskClient; use std::fmt::{Display, Formatter}; use std::net::SocketAddr; use std::sync::Arc; use std::{fmt, io, process}; -use task::TaskClient; use tokio::io::AsyncWriteExt; use tokio::net::{TcpListener, TcpStream}; use tokio_util::codec::{Decoder, Encoder, Framed}; diff --git a/common/mixnode-common/src/verloc/mod.rs b/common/mixnode-common/src/verloc/mod.rs index 53be86c791..48fe45c5b1 100644 --- a/common/mixnode-common/src/verloc/mod.rs +++ b/common/mixnode-common/src/verloc/mod.rs @@ -8,6 +8,7 @@ use futures::StreamExt; use log::*; use network_defaults::mainnet::NYM_API; use nym_crypto::asymmetric::identity; +use nym_task::TaskClient; use nym_version_checker::parse_version; use rand::seq::SliceRandom; use rand::thread_rng; @@ -15,7 +16,6 @@ use std::net::SocketAddr; use std::net::ToSocketAddrs; use std::sync::Arc; use std::time::Duration; -use task::TaskClient; use tokio::task::JoinHandle; use tokio::time::sleep; use url::Url; diff --git a/common/mixnode-common/src/verloc/sender.rs b/common/mixnode-common/src/verloc/sender.rs index 91bb596bab..665acc3145 100644 --- a/common/mixnode-common/src/verloc/sender.rs +++ b/common/mixnode-common/src/verloc/sender.rs @@ -6,12 +6,12 @@ use crate::verloc::measurement::Measurement; use crate::verloc::packet::{EchoPacket, ReplyPacket}; use log::*; use nym_crypto::asymmetric::identity; +use nym_task::TaskClient; use rand::{thread_rng, Rng}; use std::net::SocketAddr; use std::sync::Arc; use std::time::Duration; use std::{fmt, io}; -use task::TaskClient; use tokio::io::{AsyncReadExt, AsyncWriteExt}; use tokio::net::TcpStream; use tokio::time::sleep; diff --git a/common/socks5/proxy-helpers/Cargo.toml b/common/socks5/proxy-helpers/Cargo.toml index cfe89a0f12..8e7c44d1a6 100644 --- a/common/socks5/proxy-helpers/Cargo.toml +++ b/common/socks5/proxy-helpers/Cargo.toml @@ -19,7 +19,7 @@ log = { workspace = true } client-connections = { path = "../../client-connections" } ordered-buffer = { path = "../ordered-buffer" } socks5-requests = { path = "../requests" } -task = { path = "../../task" } +nym-task = { path = "../../task" } [dev-dependencies] tokio-test = "0.4.2" diff --git a/common/socks5/proxy-helpers/src/connection_controller.rs b/common/socks5/proxy-helpers/src/connection_controller.rs index 2804d4e370..79e06025c5 100644 --- a/common/socks5/proxy-helpers/src/connection_controller.rs +++ b/common/socks5/proxy-helpers/src/connection_controller.rs @@ -5,10 +5,10 @@ use client_connections::{ConnectionCommand, ConnectionCommandSender}; use futures::channel::mpsc; use futures::StreamExt; use log::*; +use nym_task::TaskClient; use ordered_buffer::{OrderedMessage, OrderedMessageBuffer, ReadContiguousData}; use socks5_requests::{ConnectionId, NetworkData, SendRequest}; use std::collections::{HashMap, HashSet}; -use task::TaskClient; /// A generic message produced after reading from a socket/connection. It includes data that was /// actually read alongside boolean indicating whether the connection got closed so that diff --git a/common/socks5/proxy-helpers/src/proxy_runner/inbound.rs b/common/socks5/proxy-helpers/src/proxy_runner/inbound.rs index c00e2ae8e5..520843167c 100644 --- a/common/socks5/proxy-helpers/src/proxy_runner/inbound.rs +++ b/common/socks5/proxy-helpers/src/proxy_runner/inbound.rs @@ -10,12 +10,12 @@ use client_connections::TransmissionLane; use futures::FutureExt; use futures::StreamExt; use log::*; +use nym_task::TaskClient; use ordered_buffer::OrderedMessageSender; use socks5_requests::ConnectionId; use std::fmt::Debug; use std::time::Duration; use std::{io, sync::Arc}; -use task::TaskClient; use tokio::select; use tokio::{net::tcp::OwnedReadHalf, sync::Notify, time::sleep}; diff --git a/common/socks5/proxy-helpers/src/proxy_runner/mod.rs b/common/socks5/proxy-helpers/src/proxy_runner/mod.rs index a87ada287e..3304cba8d2 100644 --- a/common/socks5/proxy-helpers/src/proxy_runner/mod.rs +++ b/common/socks5/proxy-helpers/src/proxy_runner/mod.rs @@ -3,10 +3,10 @@ use crate::connection_controller::ConnectionReceiver; use client_connections::LaneQueueLengths; +use nym_task::TaskClient; use socks5_requests::ConnectionId; use std::fmt::Debug; use std::{sync::Arc, time::Duration}; -use task::TaskClient; use tokio::{net::TcpStream, sync::Notify}; mod inbound; diff --git a/common/socks5/proxy-helpers/src/proxy_runner/outbound.rs b/common/socks5/proxy-helpers/src/proxy_runner/outbound.rs index 826fb9b769..f97b1b4056 100644 --- a/common/socks5/proxy-helpers/src/proxy_runner/outbound.rs +++ b/common/socks5/proxy-helpers/src/proxy_runner/outbound.rs @@ -6,9 +6,9 @@ use crate::connection_controller::{ConnectionMessage, ConnectionReceiver}; use futures::FutureExt; use futures::StreamExt; use log::*; +use nym_task::TaskClient; use socks5_requests::ConnectionId; use std::{sync::Arc, time::Duration}; -use task::TaskClient; use tokio::io::AsyncWriteExt; use tokio::select; use tokio::{net::tcp::OwnedWriteHalf, sync::Notify, time::sleep, time::Instant}; diff --git a/common/task/Cargo.toml b/common/task/Cargo.toml index ab822e9341..7e94b5442b 100644 --- a/common/task/Cargo.toml +++ b/common/task/Cargo.toml @@ -1,9 +1,11 @@ [package] -name = "task" +name = "nym-task" version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +description = "Task handling" +edition.workspace = true +authors.workspace = true +license.workspace = true +repository.workspace = true [dependencies] futures = "0.3" @@ -13,7 +15,7 @@ tokio = { version = "1.24.1", features = ["macros", "sync"] } [target."cfg(not(target_arch = \"wasm32\"))".dependencies.tokio] version = "1.24.1" -features = ["signal", "time"] +features = ["signal", "time", "rt"] [target."cfg(target_arch = \"wasm32\")".dependencies.wasm-bindgen-futures] version = "0.4" diff --git a/explorer-api/Cargo.toml b/explorer-api/Cargo.toml index 5ec59612f0..94dc7a4ec2 100644 --- a/explorer-api/Cargo.toml +++ b/explorer-api/Cargo.toml @@ -33,5 +33,5 @@ nym-mixnet-contract-common = { path = "../common/cosmwasm-smart-contracts/mixnet nym-contracts-common = { path = "../common/cosmwasm-smart-contracts/contracts-common" } network-defaults = { path = "../common/network-defaults" } logging = { path = "../common/logging"} -task = { path = "../common/task" } +nym-task = { path = "../common/task" } validator-client = { path = "../common/client-libs/validator-client", features=["nyxd-client"] } diff --git a/explorer-api/src/country_statistics/distribution.rs b/explorer-api/src/country_statistics/distribution.rs index 93d12067b6..f834b831c7 100644 --- a/explorer-api/src/country_statistics/distribution.rs +++ b/explorer-api/src/country_statistics/distribution.rs @@ -1,5 +1,5 @@ use log::info; -use task::TaskClient; +use nym_task::TaskClient; use crate::country_statistics::country_nodes_distribution::CountryNodesDistribution; use crate::COUNTRY_DATA_REFRESH_INTERVAL; diff --git a/explorer-api/src/country_statistics/geolocate.rs b/explorer-api/src/country_statistics/geolocate.rs index 0ae79985c7..8158c6e65e 100644 --- a/explorer-api/src/country_statistics/geolocate.rs +++ b/explorer-api/src/country_statistics/geolocate.rs @@ -4,7 +4,7 @@ use crate::mix_nodes::location::Location; use crate::state::ExplorerApiStateContext; use log::{info, warn}; -use task::TaskClient; +use nym_task::TaskClient; pub(crate) struct GeoLocateTask { state: ExplorerApiStateContext, diff --git a/explorer-api/src/main.rs b/explorer-api/src/main.rs index 8bf96be15f..208eaae3b9 100644 --- a/explorer-api/src/main.rs +++ b/explorer-api/src/main.rs @@ -8,7 +8,7 @@ use dotenv::dotenv; use log::info; use logging::setup_logging; use network_defaults::setup_env; -use task::TaskManager; +use nym_task::TaskManager; pub(crate) mod cache; mod client; diff --git a/explorer-api/src/tasks.rs b/explorer-api/src/tasks.rs index 264240abf2..0602a2af69 100644 --- a/explorer-api/src/tasks.rs +++ b/explorer-api/src/tasks.rs @@ -4,7 +4,7 @@ use std::future::Future; use nym_mixnet_contract_common::GatewayBond; -use task::TaskClient; +use nym_task::TaskClient; use validator_client::models::MixNodeBondAnnotated; use validator_client::nyxd::error::NyxdError; use validator_client::nyxd::{Paging, QueryNyxdClient, ValidatorResponse}; diff --git a/gateway/Cargo.toml b/gateway/Cargo.toml index 27f8bd2edf..2db8b0fd1f 100644 --- a/gateway/Cargo.toml +++ b/gateway/Cargo.toml @@ -67,7 +67,7 @@ nym-sphinx = { path = "../common/nymsphinx" } nym-pemstore = { path = "../common/pemstore" } statistics-common = { path = "../common/statistics" } nym-api-requests = { path = "../nym-api/nym-api-requests" } -task = { path = "../common/task" } +nym-task = { path = "../common/task" } validator-client = { path = "../common/client-libs/validator-client", features = [ "nyxd-client", ] } diff --git a/gateway/src/node/client_handling/websocket/connection_handler/authenticated.rs b/gateway/src/node/client_handling/websocket/connection_handler/authenticated.rs index a5a69e9980..8088f93b14 100644 --- a/gateway/src/node/client_handling/websocket/connection_handler/authenticated.rs +++ b/gateway/src/node/client_handling/websocket/connection_handler/authenticated.rs @@ -21,7 +21,7 @@ use tokio_tungstenite::tungstenite::protocol::Message; use crate::node::client_handling::bandwidth::Bandwidth; use crate::node::client_handling::FREE_TESTNET_BANDWIDTH_VALUE; use gateway_requests::iv::IV; -use task::TaskClient; +use nym_task::TaskClient; #[derive(Debug, Error)] pub(crate) enum RequestHandlingError { diff --git a/gateway/src/node/client_handling/websocket/connection_handler/fresh.rs b/gateway/src/node/client_handling/websocket/connection_handler/fresh.rs index 9347f72cf5..ebd90206bc 100644 --- a/gateway/src/node/client_handling/websocket/connection_handler/fresh.rs +++ b/gateway/src/node/client_handling/websocket/connection_handler/fresh.rs @@ -643,7 +643,7 @@ where None } - pub(crate) async fn start_handling(self, shutdown: task::TaskClient) + pub(crate) async fn start_handling(self, shutdown: nym_task::TaskClient) where S: AsyncRead + AsyncWrite + Unpin + Send, { diff --git a/gateway/src/node/client_handling/websocket/connection_handler/mod.rs b/gateway/src/node/client_handling/websocket/connection_handler/mod.rs index b11a8f21eb..bdd3efa72d 100644 --- a/gateway/src/node/client_handling/websocket/connection_handler/mod.rs +++ b/gateway/src/node/client_handling/websocket/connection_handler/mod.rs @@ -6,8 +6,8 @@ use gateway_requests::registration::handshake::SharedKeys; use gateway_requests::ServerResponse; use log::{trace, warn}; use nym_sphinx::DestinationAddressBytes; +use nym_task::TaskClient; use rand::{CryptoRng, Rng}; -use task::TaskClient; use tokio::io::{AsyncRead, AsyncWrite}; use tokio_tungstenite::WebSocketStream; diff --git a/gateway/src/node/client_handling/websocket/listener.rs b/gateway/src/node/client_handling/websocket/listener.rs index 1cf3e68072..02882cebc0 100644 --- a/gateway/src/node/client_handling/websocket/listener.rs +++ b/gateway/src/node/client_handling/websocket/listener.rs @@ -43,7 +43,7 @@ impl Listener { outbound_mix_sender: MixForwardingSender, storage: St, active_clients_store: ActiveClientsStore, - mut shutdown: task::TaskClient, + mut shutdown: nym_task::TaskClient, ) where St: Storage + Clone + 'static, { @@ -94,7 +94,7 @@ impl Listener { outbound_mix_sender: MixForwardingSender, storage: St, active_clients_store: ActiveClientsStore, - shutdown: task::TaskClient, + shutdown: nym_task::TaskClient, ) -> JoinHandle<()> where St: Storage + Clone + 'static, diff --git a/gateway/src/node/mixnet_handling/receiver/connection_handler.rs b/gateway/src/node/mixnet_handling/receiver/connection_handler.rs index 14c9725adc..bd566f5c2f 100644 --- a/gateway/src/node/mixnet_handling/receiver/connection_handler.rs +++ b/gateway/src/node/mixnet_handling/receiver/connection_handler.rs @@ -14,9 +14,9 @@ use nym_sphinx::forwarding::packet::MixPacket; use nym_sphinx::framing::codec::SphinxCodec; use nym_sphinx::framing::packet::FramedSphinxPacket; use nym_sphinx::DestinationAddressBytes; +use nym_task::TaskClient; use std::collections::HashMap; use std::net::SocketAddr; -use task::TaskClient; use tokio::net::TcpStream; use tokio_util::codec::Framed; diff --git a/gateway/src/node/mixnet_handling/receiver/listener.rs b/gateway/src/node/mixnet_handling/receiver/listener.rs index 88bca3e2c8..38fd8ef43b 100644 --- a/gateway/src/node/mixnet_handling/receiver/listener.rs +++ b/gateway/src/node/mixnet_handling/receiver/listener.rs @@ -4,9 +4,9 @@ use crate::node::mixnet_handling::receiver::connection_handler::ConnectionHandler; use crate::node::storage::Storage; use log::*; +use nym_task::TaskClient; use std::net::SocketAddr; use std::process; -use task::TaskClient; use tokio::task::JoinHandle; pub(crate) struct Listener { diff --git a/gateway/src/node/mod.rs b/gateway/src/node/mod.rs index 6a3300affd..3fa11671d4 100644 --- a/gateway/src/node/mod.rs +++ b/gateway/src/node/mod.rs @@ -18,6 +18,7 @@ use log::*; use mixnet_client::forwarder::{MixForwardingSender, PacketForwarder}; use network_defaults::NymNetworkDetails; use nym_crypto::asymmetric::{encryption, identity}; +use nym_task::{TaskClient, TaskManager}; use rand::seq::SliceRandom; use rand::thread_rng; use statistics_common::collector::StatisticsSender; @@ -25,7 +26,6 @@ use std::error::Error; use std::net::SocketAddr; use std::process; use std::sync::Arc; -use task::{TaskClient, TaskManager}; use validator_client::Client; pub(crate) mod client_handling; diff --git a/mixnode/Cargo.toml b/mixnode/Cargo.toml index 21c2534fc1..fd57ab1775 100644 --- a/mixnode/Cargo.toml +++ b/mixnode/Cargo.toml @@ -50,7 +50,7 @@ mixnode-common = { path="../common/mixnode-common" } nonexhaustive-delayqueue = { path="../common/nonexhaustive-delayqueue" } nym-sphinx = { path="../common/nymsphinx" } nym-pemstore = { path = "../common/pemstore", version = "0.1.0" } -task = { path = "../common/task" } +nym-task = { path = "../common/task" } nym-types = { path = "../common/types" } nym-topology = { path="../common/topology" } validator-client = { path="../common/client-libs/validator-client" } diff --git a/mixnode/src/node/mod.rs b/mixnode/src/node/mod.rs index 6624e74a56..5bc0c73d35 100644 --- a/mixnode/src/node/mod.rs +++ b/mixnode/src/node/mod.rs @@ -23,13 +23,13 @@ use config::NymConfig; use log::{error, info, warn}; use mixnode_common::verloc::{self, AtomicVerlocResult, VerlocMeasurer}; use nym_crypto::asymmetric::{encryption, identity}; +use nym_task::{TaskClient, TaskManager}; use nym_version_checker::parse_version; use rand::seq::SliceRandom; use rand::thread_rng; use std::net::SocketAddr; use std::process; use std::sync::Arc; -use task::{TaskClient, TaskManager}; mod http; mod listener; diff --git a/mixnode/src/node/node_statistics.rs b/mixnode/src/node/node_statistics.rs index 2fa8c39b8e..2187d77a91 100644 --- a/mixnode/src/node/node_statistics.rs +++ b/mixnode/src/node/node_statistics.rs @@ -503,7 +503,7 @@ impl Controller { #[cfg(test)] mod tests { use super::*; - use task::TaskManager; + use nym_task::TaskManager; #[tokio::test] async fn node_stats_reported_are_received() { diff --git a/mixnode/src/node/packet_delayforwarder.rs b/mixnode/src/node/packet_delayforwarder.rs index c4958f8708..557440301f 100644 --- a/mixnode/src/node/packet_delayforwarder.rs +++ b/mixnode/src/node/packet_delayforwarder.rs @@ -134,7 +134,7 @@ mod tests { use std::sync::{Arc, Mutex}; use std::time::Duration; - use task::TaskManager; + use nym_task::TaskManager; use nym_sphinx::addressing::nodes::NymNodeRoutingAddress; use nym_sphinx_params::packet_sizes::PacketSize; diff --git a/nym-api/Cargo.toml b/nym-api/Cargo.toml index a9801a7bc1..2a9f60630f 100644 --- a/nym-api/Cargo.toml +++ b/nym-api/Cargo.toml @@ -87,7 +87,7 @@ multisig-contract-common = { path = "../common/cosmwasm-smart-contracts/multisig nymcoconut = { path = "../common/nymcoconut" } nym-sphinx = { path = "../common/nymsphinx" } nym-pemstore = { path = "../common/pemstore" } -task = { path = "../common/task" } +nym-task = { path = "../common/task" } nym-topology = { path = "../common/topology" } nym-api-requests = { path = "nym-api-requests" } validator-client = { path = "../common/client-libs/validator-client", features = [ diff --git a/nym-api/src/circulating_supply_api/cache/refresher.rs b/nym-api/src/circulating_supply_api/cache/refresher.rs index 75f6e5cdc2..c28859eb15 100644 --- a/nym-api/src/circulating_supply_api/cache/refresher.rs +++ b/nym-api/src/circulating_supply_api/cache/refresher.rs @@ -5,10 +5,10 @@ use super::CirculatingSupplyCache; use crate::circulating_supply_api::cache::CirculatingSupplyCacheError; use crate::support::nyxd::Client; use nym_contracts_common::truncate_decimal; +use nym_task::TaskClient; use std::collections::HashSet; use std::sync::atomic::Ordering; use std::time::Duration; -use task::TaskClient; use tokio::time; use validator_client::nyxd::Coin; diff --git a/nym-api/src/circulating_supply_api/mod.rs b/nym-api/src/circulating_supply_api/mod.rs index 900d38380b..39dfe28edc 100644 --- a/nym-api/src/circulating_supply_api/mod.rs +++ b/nym-api/src/circulating_supply_api/mod.rs @@ -1,10 +1,10 @@ // Copyright 2022-2023 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 +use nym_task::TaskManager; use okapi::openapi3::OpenApi; use rocket::Route; use rocket_okapi::{openapi_get_routes_spec, settings::OpenApiSettings}; -use task::TaskManager; use crate::support::{config::Config, nyxd}; diff --git a/nym-api/src/coconut/dkg/controller.rs b/nym-api/src/coconut/dkg/controller.rs index 26f693e73b..6ae32cfad5 100644 --- a/nym-api/src/coconut/dkg/controller.rs +++ b/nym-api/src/coconut/dkg/controller.rs @@ -16,11 +16,11 @@ use crate::support::config::Config; use anyhow::Result; use coconut_dkg_common::types::EpochState; use dkg::bte::keys::KeyPair as DkgKeyPair; +use nym_task::{TaskClient, TaskManager}; use rand::rngs::OsRng; use rand::RngCore; use std::path::PathBuf; use std::time::{Duration, SystemTime}; -use task::{TaskClient, TaskManager}; use tokio::time::interval; pub(crate) fn init_keypair(config: &Config) -> Result<()> { diff --git a/nym-api/src/epoch_operations/mod.rs b/nym-api/src/epoch_operations/mod.rs index f4e13d691f..ab8194f17e 100644 --- a/nym-api/src/epoch_operations/mod.rs +++ b/nym-api/src/epoch_operations/mod.rs @@ -24,12 +24,12 @@ use nym_mixnet_contract_common::{ reward_params::Performance, CurrentIntervalResponse, ExecuteMsg, Interval, MixId, }; use nym_mixnet_contract_common::{IdentityKey, Layer, LayerAssignment, MixNodeDetails}; +use nym_task::{TaskClient, TaskManager}; use rand::prelude::SliceRandom; use rand::rngs::OsRng; use std::collections::HashMap; use std::collections::HashSet; use std::time::Duration; -use task::{TaskClient, TaskManager}; use tokio::time::sleep; pub(crate) mod error; diff --git a/nym-api/src/main.rs b/nym-api/src/main.rs index 4258fe53c1..7711db94ca 100644 --- a/nym-api/src/main.rs +++ b/nym-api/src/main.rs @@ -21,10 +21,10 @@ use log::info; use logging::setup_logging; use node_status_api::NodeStatusCache; use nym_contract_cache::cache::NymContractCache; +use nym_task::TaskManager; use rand::rngs::OsRng; use std::error::Error; use support::{http, nyxd}; -use task::TaskManager; mod circulating_supply_api; mod coconut; diff --git a/nym-api/src/network_monitor/mod.rs b/nym-api/src/network_monitor/mod.rs index 49ceca5768..4e32c61f7b 100644 --- a/nym-api/src/network_monitor/mod.rs +++ b/nym-api/src/network_monitor/mod.rs @@ -20,8 +20,8 @@ use credential_storage::PersistentStorage; use futures::channel::mpsc; use gateway_client::bandwidth::BandwidthController; use nym_crypto::asymmetric::{encryption, identity}; +use nym_task::TaskManager; use std::sync::Arc; -use task::TaskManager; use validator_client::nyxd::SigningNyxdClient; pub(crate) mod chunker; diff --git a/nym-api/src/network_monitor/monitor/gateways_pinger.rs b/nym-api/src/network_monitor/monitor/gateways_pinger.rs index e3ad14a77b..4d0a0e7f0e 100644 --- a/nym-api/src/network_monitor/monitor/gateways_pinger.rs +++ b/nym-api/src/network_monitor/monitor/gateways_pinger.rs @@ -6,8 +6,8 @@ use crate::network_monitor::monitor::receiver::{GatewayClientUpdate, GatewayClie use log::{debug, info, trace, warn}; use nym_crypto::asymmetric::identity; use nym_crypto::asymmetric::identity::PUBLIC_KEY_LENGTH; +use nym_task::TaskClient; use std::time::Duration; -use task::TaskClient; use tokio::time::{sleep, Instant}; // TODO: should it perhaps be moved to config along other timeout values? diff --git a/nym-api/src/network_monitor/monitor/mod.rs b/nym-api/src/network_monitor/monitor/mod.rs index d3cb775f26..5fa7ef0793 100644 --- a/nym-api/src/network_monitor/monitor/mod.rs +++ b/nym-api/src/network_monitor/monitor/mod.rs @@ -10,9 +10,9 @@ use crate::network_monitor::test_route::TestRoute; use crate::storage::NymApiStorage; use crate::support::config::Config; use log::{debug, error, info}; +use nym_task::TaskClient; use std::collections::{HashMap, HashSet}; use std::process; -use task::TaskClient; use tokio::time::{sleep, Duration, Instant}; pub(crate) mod gateway_clients_cache; diff --git a/nym-api/src/network_monitor/monitor/receiver.rs b/nym-api/src/network_monitor/monitor/receiver.rs index f9b45f402e..fd7d441b30 100644 --- a/nym-api/src/network_monitor/monitor/receiver.rs +++ b/nym-api/src/network_monitor/monitor/receiver.rs @@ -7,7 +7,7 @@ use futures::channel::mpsc; use futures::StreamExt; use gateway_client::{AcknowledgementReceiver, MixnetMessageReceiver}; use nym_crypto::asymmetric::identity; -use task::TaskClient; +use nym_task::TaskClient; pub(crate) type GatewayClientUpdateSender = mpsc::UnboundedSender; pub(crate) type GatewayClientUpdateReceiver = mpsc::UnboundedReceiver; diff --git a/nym-api/src/network_monitor/monitor/sender.rs b/nym-api/src/network_monitor/monitor/sender.rs index 432dd122e0..6911cd0dbb 100644 --- a/nym-api/src/network_monitor/monitor/sender.rs +++ b/nym-api/src/network_monitor/monitor/sender.rs @@ -17,6 +17,7 @@ use gateway_client::{AcknowledgementReceiver, GatewayClient, MixnetMessageReceiv use log::{debug, info, trace, warn}; use nym_crypto::asymmetric::identity::{self, PUBLIC_KEY_LENGTH}; use nym_sphinx::forwarding::packet::MixPacket; +use nym_task::TaskClient; use pin_project::pin_project; use std::mem; use std::num::NonZeroUsize; @@ -24,7 +25,6 @@ use std::pin::Pin; use std::sync::Arc; use std::task::Poll; use std::time::Duration; -use task::TaskClient; use gateway_client::bandwidth::BandwidthController; use validator_client::nyxd::SigningNyxdClient; @@ -194,7 +194,7 @@ impl PacketSender { ack_sender, fresh_gateway_client_data.gateway_response_timeout, Some(fresh_gateway_client_data.bandwidth_controller.clone()), - task::TaskClient::dummy(), + nym_task::TaskClient::dummy(), ); gateway_client diff --git a/nym-api/src/node_status_api/cache/refresher.rs b/nym-api/src/node_status_api/cache/refresher.rs index 704aaca203..146e75ebfb 100644 --- a/nym-api/src/node_status_api/cache/refresher.rs +++ b/nym-api/src/node_status_api/cache/refresher.rs @@ -12,8 +12,8 @@ use crate::{ storage::NymApiStorage, support::caching::CacheNotification, }; +use nym_task::TaskClient; use std::time::Duration; -use task::TaskClient; use tokio::sync::watch; use tokio::time; diff --git a/nym-api/src/node_status_api/mod.rs b/nym-api/src/node_status_api/mod.rs index 8b403ad4c8..c8b3718fa6 100644 --- a/nym-api/src/node_status_api/mod.rs +++ b/nym-api/src/node_status_api/mod.rs @@ -2,11 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 pub(crate) use cache::NodeStatusCache; +use nym_task::TaskManager; use okapi::openapi3::OpenApi; use rocket::Route; use rocket_okapi::{openapi_get_routes_spec, settings::OpenApiSettings}; use std::time::Duration; -use task::TaskManager; use crate::{ nym_contract_cache::cache::NymContractCache, diff --git a/nym-api/src/node_status_api/uptime_updater.rs b/nym-api/src/node_status_api/uptime_updater.rs index e17dc9354a..78d4116e11 100644 --- a/nym-api/src/node_status_api/uptime_updater.rs +++ b/nym-api/src/node_status_api/uptime_updater.rs @@ -7,8 +7,8 @@ use crate::node_status_api::models::{ use crate::node_status_api::ONE_DAY; use crate::storage::NymApiStorage; use log::error; +use nym_task::{TaskClient, TaskManager}; use std::time::Duration; -use task::{TaskClient, TaskManager}; use time::{OffsetDateTime, PrimitiveDateTime, Time}; use tokio::time::{interval, sleep}; diff --git a/nym-api/src/nym_contract_cache/cache/refresher.rs b/nym-api/src/nym_contract_cache/cache/refresher.rs index 8f1bd1df4a..4f3241a7aa 100644 --- a/nym-api/src/nym_contract_cache/cache/refresher.rs +++ b/nym-api/src/nym_contract_cache/cache/refresher.rs @@ -3,8 +3,8 @@ use crate::nyxd::Client; use crate::support::caching::CacheNotification; use anyhow::Result; use nym_mixnet_contract_common::{MixId, MixNodeDetails, RewardedSetNodeStatus}; +use nym_task::TaskClient; use std::{collections::HashMap, sync::atomic::Ordering, time::Duration}; -use task::TaskClient; use tokio::sync::watch; use tokio::time; diff --git a/nym-api/src/nym_contract_cache/mod.rs b/nym-api/src/nym_contract_cache/mod.rs index 242cb8ae7a..e3f4ef267c 100644 --- a/nym-api/src/nym_contract_cache/mod.rs +++ b/nym-api/src/nym_contract_cache/mod.rs @@ -4,11 +4,11 @@ use crate::nym_contract_cache::cache::NymContractCache; use crate::support::config::Config; use crate::support::{self, nyxd}; +use nym_task::TaskManager; use okapi::openapi3::OpenApi; use rocket::Route; use rocket_okapi::openapi_get_routes_spec; use rocket_okapi::settings::OpenApiSettings; -use task::TaskManager; use self::cache::refresher::NymContractCacheRefresher; diff --git a/nym-connect-android/src-tauri/Cargo.lock b/nym-connect-android/src-tauri/Cargo.lock index 1d419591d2..36202e1a32 100644 --- a/nym-connect-android/src-tauri/Cargo.lock +++ b/nym-connect-android/src-tauri/Cargo.lock @@ -644,18 +644,18 @@ dependencies = [ "nonexhaustive-delayqueue", "nym-crypto", "nym-pemstore", - "nymsphinx", + "nym-sphinx", + "nym-task", + "nym-topology", "rand 0.7.3", "serde", "serde_json", "sqlx 0.6.2", "tap", - "task", "thiserror", "time 0.3.18", "tokio", "tokio-stream", - "topology", "url", "validator-client", "wasm-bindgen", @@ -1977,10 +1977,10 @@ dependencies = [ "network-defaults", "nym-crypto", "nym-pemstore", - "nymsphinx", + "nym-sphinx", + "nym-task", "rand 0.7.3", "serde", - "task", "thiserror", "tokio", "tokio-stream", @@ -2005,7 +2005,7 @@ dependencies = [ "log", "nym-crypto", "nym-pemstore", - "nymsphinx", + "nym-sphinx", "rand 0.7.3", "serde", "serde_json", @@ -3562,6 +3562,7 @@ dependencies = [ "nym-contracts-common", "nym-crypto", "nym-socks5-client", + "nym-task", "pretty_env_logger", "rand 0.8.5", "reqwest", @@ -3570,14 +3571,12 @@ dependencies = [ "serde_json", "serde_repr", "tap", - "task", "tauri", "tauri-build", "tempfile", "tendermint-rpc", "thiserror", "tokio", - "topology", "ts-rs", "url", "yaml-rust", @@ -3609,7 +3608,7 @@ dependencies = [ "hkdf 0.12.3", "hmac 0.12.1", "nym-pemstore", - "nymsphinx-types", + "nym-sphinx-types", "rand 0.7.3", "subtle-encoding", "thiserror", @@ -3663,7 +3662,10 @@ dependencies = [ "network-defaults", "nym-crypto", "nym-pemstore", - "nymsphinx", + "nym-sphinx", + "nym-task", + "nym-topology", + "nym-version-checker", "ordered-buffer", "pin-project", "pretty_env_logger", @@ -3674,13 +3676,169 @@ dependencies = [ "service-providers-common", "socks5-requests", "tap", - "task", "thiserror", "tokio", - "topology", "url", "validator-client", - "version-checker", +] + +[[package]] +name = "nym-sphinx" +version = "0.1.0" +dependencies = [ + "nym-crypto", + "nym-sphinx-acknowledgements", + "nym-sphinx-addressing", + "nym-sphinx-anonymous-replies", + "nym-sphinx-chunking", + "nym-sphinx-cover", + "nym-sphinx-forwarding", + "nym-sphinx-framing", + "nym-sphinx-params", + "nym-sphinx-types", + "nym-topology", + "rand 0.7.3", + "rand_distr", + "thiserror", + "tokio", +] + +[[package]] +name = "nym-sphinx-acknowledgements" +version = "0.1.0" +dependencies = [ + "nym-crypto", + "nym-pemstore", + "nym-sphinx-addressing", + "nym-sphinx-params", + "nym-sphinx-types", + "nym-topology", + "rand 0.7.3", + "thiserror", +] + +[[package]] +name = "nym-sphinx-addressing" +version = "0.1.0" +dependencies = [ + "nym-crypto", + "nym-sphinx-types", + "serde", + "thiserror", +] + +[[package]] +name = "nym-sphinx-anonymous-replies" +version = "0.1.0" +dependencies = [ + "bs58", + "nym-crypto", + "nym-sphinx-addressing", + "nym-sphinx-params", + "nym-sphinx-types", + "nym-topology", + "rand 0.7.3", + "serde", + "thiserror", + "wasm-bindgen", +] + +[[package]] +name = "nym-sphinx-chunking" +version = "0.1.0" +dependencies = [ + "log", + "nym-sphinx-addressing", + "nym-sphinx-params", + "nym-sphinx-types", + "rand 0.7.3", + "thiserror", +] + +[[package]] +name = "nym-sphinx-cover" +version = "0.1.0" +dependencies = [ + "nym-crypto", + "nym-sphinx-acknowledgements", + "nym-sphinx-addressing", + "nym-sphinx-chunking", + "nym-sphinx-forwarding", + "nym-sphinx-params", + "nym-sphinx-types", + "nym-topology", + "rand 0.7.3", + "thiserror", +] + +[[package]] +name = "nym-sphinx-forwarding" +version = "0.1.0" +dependencies = [ + "nym-sphinx-addressing", + "nym-sphinx-params", + "nym-sphinx-types", +] + +[[package]] +name = "nym-sphinx-framing" +version = "0.1.0" +dependencies = [ + "bytes", + "nym-sphinx-params", + "nym-sphinx-types", + "thiserror", + "tokio-util", +] + +[[package]] +name = "nym-sphinx-params" +version = "0.1.0" +dependencies = [ + "nym-crypto", + "nym-sphinx-types", + "thiserror", +] + +[[package]] +name = "nym-sphinx-types" +version = "0.1.0" +dependencies = [ + "sphinx", +] + +[[package]] +name = "nym-task" +version = "0.1.0" +dependencies = [ + "futures", + "log", + "thiserror", + "tokio", + "wasm-bindgen", + "wasm-bindgen-futures", +] + +[[package]] +name = "nym-topology" +version = "0.1.0" +dependencies = [ + "bs58", + "log", + "nym-crypto", + "nym-mixnet-contract-common", + "nym-sphinx-addressing", + "nym-sphinx-types", + "nym-version-checker", + "rand 0.7.3", + "thiserror", +] + +[[package]] +name = "nym-version-checker" +version = "0.1.0" +dependencies = [ + "semver 0.11.0", ] [[package]] @@ -3729,131 +3887,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "nymsphinx" -version = "0.1.0" -dependencies = [ - "nym-crypto", - "nymsphinx-acknowledgements", - "nymsphinx-addressing", - "nymsphinx-anonymous-replies", - "nymsphinx-chunking", - "nymsphinx-cover", - "nymsphinx-forwarding", - "nymsphinx-framing", - "nymsphinx-params", - "nymsphinx-types", - "rand 0.7.3", - "rand_distr", - "thiserror", - "tokio", - "topology", -] - -[[package]] -name = "nymsphinx-acknowledgements" -version = "0.1.0" -dependencies = [ - "nym-crypto", - "nym-pemstore", - "nymsphinx-addressing", - "nymsphinx-params", - "nymsphinx-types", - "rand 0.7.3", - "thiserror", - "topology", -] - -[[package]] -name = "nymsphinx-addressing" -version = "0.1.0" -dependencies = [ - "nym-crypto", - "nymsphinx-types", - "serde", - "thiserror", -] - -[[package]] -name = "nymsphinx-anonymous-replies" -version = "0.1.0" -dependencies = [ - "bs58", - "nym-crypto", - "nymsphinx-addressing", - "nymsphinx-params", - "nymsphinx-types", - "rand 0.7.3", - "serde", - "thiserror", - "topology", - "wasm-bindgen", -] - -[[package]] -name = "nymsphinx-chunking" -version = "0.1.0" -dependencies = [ - "log", - "nymsphinx-addressing", - "nymsphinx-params", - "nymsphinx-types", - "rand 0.7.3", - "thiserror", -] - -[[package]] -name = "nymsphinx-cover" -version = "0.1.0" -dependencies = [ - "nym-crypto", - "nymsphinx-acknowledgements", - "nymsphinx-addressing", - "nymsphinx-chunking", - "nymsphinx-forwarding", - "nymsphinx-params", - "nymsphinx-types", - "rand 0.7.3", - "thiserror", - "topology", -] - -[[package]] -name = "nymsphinx-forwarding" -version = "0.1.0" -dependencies = [ - "nymsphinx-addressing", - "nymsphinx-params", - "nymsphinx-types", -] - -[[package]] -name = "nymsphinx-framing" -version = "0.1.0" -dependencies = [ - "bytes", - "nymsphinx-params", - "nymsphinx-types", - "thiserror", - "tokio-util", -] - -[[package]] -name = "nymsphinx-params" -version = "0.1.0" -dependencies = [ - "nym-crypto", - "nymsphinx-types", - "thiserror", -] - -[[package]] -name = "nymsphinx-types" -version = "0.1.0" -dependencies = [ - "sphinx", -] - [[package]] name = "objc" version = "0.2.7" @@ -4482,9 +4515,9 @@ dependencies = [ "client-connections", "futures", "log", + "nym-task", "ordered-buffer", "socks5-requests", - "task", "tokio", "tokio-util", ] @@ -5331,7 +5364,7 @@ dependencies = [ "async-trait", "build-information", "log", - "nymsphinx-anonymous-replies", + "nym-sphinx-anonymous-replies", "serde", "serde_json", "thiserror", @@ -5479,7 +5512,7 @@ dependencies = [ name = "socks5-requests" version = "0.1.0" dependencies = [ - "nymsphinx-addressing", + "nym-sphinx-addressing", "serde", "serde_json", "service-providers-common", @@ -5981,18 +6014,6 @@ dependencies = [ "xattr", ] -[[package]] -name = "task" -version = "0.1.0" -dependencies = [ - "futures", - "log", - "thiserror", - "tokio", - "wasm-bindgen", - "wasm-bindgen-futures", -] - [[package]] name = "tauri" version = "2.0.0-alpha.3" @@ -6527,21 +6548,6 @@ dependencies = [ "toml_datetime", ] -[[package]] -name = "topology" -version = "0.1.0" -dependencies = [ - "bs58", - "log", - "nym-crypto", - "nym-mixnet-contract-common", - "nymsphinx-addressing", - "nymsphinx-types", - "rand 0.7.3", - "thiserror", - "version-checker", -] - [[package]] name = "tower-service" version = "0.3.2" @@ -6867,13 +6873,6 @@ dependencies = [ "time 0.3.18", ] -[[package]] -name = "version-checker" -version = "0.1.0" -dependencies = [ - "semver 0.11.0", -] - [[package]] name = "version-compare" version = "0.1.1" diff --git a/nym-connect-android/src-tauri/Cargo.toml b/nym-connect-android/src-tauri/Cargo.toml index 63cfe55553..2971937987 100644 --- a/nym-connect-android/src-tauri/Cargo.toml +++ b/nym-connect-android/src-tauri/Cargo.toml @@ -53,7 +53,7 @@ config-common = { path = "../../common/config", package = "config" } nym-crypto = { path = "../../common/crypto" } logging = { path = "../../common/logging"} nym-socks5-client = { path = "../../clients/socks5", features = ["mobile"], default-features = false } -task = { path = "../../common/task" } +nym-task = { path = "../../common/task" } [dev-dependencies] ts-rs = "6.1.2" diff --git a/nym-connect-android/src-tauri/src/events.rs b/nym-connect-android/src-tauri/src/events.rs index 13e1ca800d..cf277a90f9 100644 --- a/nym-connect-android/src-tauri/src/events.rs +++ b/nym-connect-android/src-tauri/src/events.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use client_core::error::ClientCoreStatusMessage; -use task::manager::TaskStatus; +use nym_task::manager::TaskStatus; use tauri::async_runtime::RwLock; use crate::{ diff --git a/nym-connect-android/src-tauri/src/state.rs b/nym-connect-android/src-tauri/src/state.rs index 0af63ce1e0..e3cff0a105 100644 --- a/nym-connect-android/src-tauri/src/state.rs +++ b/nym-connect-android/src-tauri/src/state.rs @@ -171,7 +171,7 @@ impl State { pub async fn start_connecting( &mut self, window: &tauri::Window, - ) -> Result<(task::StatusReceiver, ExitStatusReceiver)> { + ) -> Result<(nym_task::StatusReceiver, ExitStatusReceiver)> { self.set_state(ConnectionStatusKind::Connecting, window); let res = self.init_config().await; @@ -214,7 +214,7 @@ impl State { &mut self, config: Config, keys: KeyManager, - ) -> Result<(task::StatusReceiver, ExitStatusReceiver)> { + ) -> Result<(nym_task::StatusReceiver, ExitStatusReceiver)> { let id = self.get_config_id()?; let (control_tx, msg_rx, exit_status_rx, used_gateway) = tasks::start_nym_socks5_client(&id, config, keys)?; diff --git a/nym-connect-android/src-tauri/src/tasks.rs b/nym-connect-android/src-tauri/src/tasks.rs index eb6f691825..58f7d8469f 100644 --- a/nym-connect-android/src-tauri/src/tasks.rs +++ b/nym-connect-android/src-tauri/src/tasks.rs @@ -4,9 +4,9 @@ use client_core::{ error::ClientCoreStatusMessage, }; use futures::{channel::mpsc, StreamExt}; +use nym_task::manager::TaskStatus; use std::sync::Arc; use tap::TapFallible; -use task::manager::TaskStatus; use tokio::sync::RwLock; use config_common::NymConfig; @@ -40,7 +40,7 @@ pub fn start_nym_socks5_client( keys: KeyManager, ) -> Result<( Socks5ControlMessageSender, - task::StatusReceiver, + nym_task::StatusReceiver, ExitStatusReceiver, GatewayEndpointConfig, )> { @@ -138,7 +138,7 @@ pub fn start_connection_check(state: Arc>, window: tauri::Window>, window: tauri::Window, - mut msg_receiver: task::StatusReceiver, + mut msg_receiver: nym_task::StatusReceiver, ) { log::info!("Starting status listener"); diff --git a/nym-connect/src-tauri/Cargo.toml b/nym-connect/src-tauri/Cargo.toml index a5ceea91db..887360b22f 100644 --- a/nym-connect/src-tauri/Cargo.toml +++ b/nym-connect/src-tauri/Cargo.toml @@ -51,7 +51,7 @@ config-common = { path = "../../common/config", package = "config" } nym-crypto = { path = "../../common/crypto" } logging = { path = "../../common/logging"} nym-socks5-client = { path = "../../clients/socks5" } -task = { path = "../../common/task" } +nym-task = { path = "../../common/task" } [dev-dependencies] ts-rs = "6.1.2" diff --git a/nym-connect/src-tauri/src/events.rs b/nym-connect/src-tauri/src/events.rs index 13e1ca800d..cf277a90f9 100644 --- a/nym-connect/src-tauri/src/events.rs +++ b/nym-connect/src-tauri/src/events.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use client_core::error::ClientCoreStatusMessage; -use task::manager::TaskStatus; +use nym_task::manager::TaskStatus; use tauri::async_runtime::RwLock; use crate::{ diff --git a/nym-connect/src-tauri/src/state.rs b/nym-connect/src-tauri/src/state.rs index 949adfe8dc..2262ca316b 100644 --- a/nym-connect/src-tauri/src/state.rs +++ b/nym-connect/src-tauri/src/state.rs @@ -164,7 +164,7 @@ impl State { pub async fn start_connecting( &mut self, window: &tauri::Window, - ) -> Result<(task::StatusReceiver, ExitStatusReceiver)> { + ) -> Result<(nym_task::StatusReceiver, ExitStatusReceiver)> { self.set_state(ConnectionStatusKind::Connecting, window); // Setup configuration by writing to file @@ -199,7 +199,9 @@ impl State { } /// Spawn a new thread running the SOCKS5 client - fn start_nym_socks5_client(&mut self) -> Result<(task::StatusReceiver, ExitStatusReceiver)> { + fn start_nym_socks5_client( + &mut self, + ) -> Result<(nym_task::StatusReceiver, ExitStatusReceiver)> { let id = self.get_config_id()?; let (control_tx, msg_rx, exit_status_rx, used_gateway) = tasks::start_nym_socks5_client(&id)?; diff --git a/nym-connect/src-tauri/src/tasks.rs b/nym-connect/src-tauri/src/tasks.rs index 1cf53b55d3..389ce7a733 100644 --- a/nym-connect/src-tauri/src/tasks.rs +++ b/nym-connect/src-tauri/src/tasks.rs @@ -3,9 +3,9 @@ use client_core::{ error::ClientCoreStatusMessage, }; use futures::{channel::mpsc, StreamExt}; +use nym_task::manager::TaskStatus; use std::sync::Arc; use tap::TapFallible; -use task::manager::TaskStatus; use tokio::sync::RwLock; use config_common::NymConfig; @@ -36,7 +36,7 @@ pub fn start_nym_socks5_client( id: &str, ) -> Result<( Socks5ControlMessageSender, - task::StatusReceiver, + nym_task::StatusReceiver, ExitStatusReceiver, GatewayEndpointConfig, )> { @@ -136,7 +136,7 @@ pub fn start_connection_check(state: Arc>, window: tauri::Window>, window: tauri::Window, - mut msg_receiver: task::StatusReceiver, + mut msg_receiver: nym_task::StatusReceiver, ) { log::info!("Starting status listener"); diff --git a/sdk/rust/nym-sdk/Cargo.toml b/sdk/rust/nym-sdk/Cargo.toml index 2fe416a829..67bad0b816 100644 --- a/sdk/rust/nym-sdk/Cargo.toml +++ b/sdk/rust/nym-sdk/Cargo.toml @@ -13,7 +13,7 @@ gateway-client = { path = "../../../common/client-libs/gateway-client" } gateway-requests = { path = "../../../gateway/gateway-requests" } network-defaults = { path = "../../../common/network-defaults" } nym-sphinx = { path = "../../../common/nymsphinx" } -task = { path = "../../../common/task" } +nym-task = { path = "../../../common/task" } validator-client = { path = "../../../common/client-libs/validator-client", features = ["nyxd-client"] } futures = "0.3" diff --git a/sdk/rust/nym-sdk/src/mixnet/client.rs b/sdk/rust/nym-sdk/src/mixnet/client.rs index fc5b216c64..11b5113d43 100644 --- a/sdk/rust/nym-sdk/src/mixnet/client.rs +++ b/sdk/rust/nym-sdk/src/mixnet/client.rs @@ -18,7 +18,7 @@ use nym_sphinx::{ addressing::clients::{ClientIdentity, Recipient}, receiver::ReconstructedMessage, }; -use task::TaskManager; +use nym_task::TaskManager; use futures::StreamExt; use validator_client::nyxd::SigningNyxdClient; diff --git a/service-providers/network-requester/Cargo.toml b/service-providers/network-requester/Cargo.toml index 873b39521b..42b8a7a6f9 100644 --- a/service-providers/network-requester/Cargo.toml +++ b/service-providers/network-requester/Cargo.toml @@ -46,6 +46,6 @@ proxy-helpers = { path = "../../common/socks5/proxy-helpers" } service-providers-common = { path = "../common" } socks5-requests = { path = "../../common/socks5/requests" } statistics-common = { path = "../../common/statistics" } -task = { path = "../../common/task" } +nym-task = { path = "../../common/task" } nym-version-checker = { path = "../../common/version-checker" } websocket-requests = { path = "../../clients/native/websocket-requests" } diff --git a/service-providers/network-requester/src/core.rs b/service-providers/network-requester/src/core.rs index 6dc0a7da00..da0e8821f6 100644 --- a/service-providers/network-requester/src/core.rs +++ b/service-providers/network-requester/src/core.rs @@ -15,6 +15,7 @@ use futures::channel::mpsc; use log::warn; use nym_sphinx::addressing::clients::Recipient; use nym_sphinx::anonymous_replies::requests::AnonymousSenderTag; +use nym_task::{TaskClient, TaskManager}; use proxy_helpers::connection_controller::{Controller, ControllerCommand, ControllerSender}; use proxy_helpers::proxy_runner::{MixProxyReader, MixProxySender}; use service_providers_common::interface::{ @@ -28,7 +29,6 @@ use socks5_requests::{ use statistics_common::collector::StatisticsSender; use std::path::PathBuf; use std::sync::atomic::{AtomicUsize, Ordering}; -use task::{TaskClient, TaskManager}; // Since it's an atomic, it's safe to be kept static and shared across threads static ACTIVE_PROXIES: AtomicUsize = AtomicUsize::new(0); @@ -188,7 +188,7 @@ impl NRServiceProviderBuilder { let (mix_input_sender, mix_input_receiver) = tokio::sync::mpsc::channel::(1); // Used to notify tasks to shutdown. Not all tasks fully supports this (yet). - let shutdown = task::TaskManager::default(); + let shutdown = nym_task::TaskManager::default(); // Controller for managing all active connections. let (mut active_connections_controller, controller_sender) = Controller::new( diff --git a/service-providers/network-requester/src/socks5/tcp.rs b/service-providers/network-requester/src/socks5/tcp.rs index e5ddd8a5c0..45f173c1c7 100644 --- a/service-providers/network-requester/src/socks5/tcp.rs +++ b/service-providers/network-requester/src/socks5/tcp.rs @@ -4,12 +4,12 @@ use crate::reply; use crate::reply::MixnetMessage; use client_connections::LaneQueueLengths; +use nym_task::TaskClient; use proxy_helpers::connection_controller::ConnectionReceiver; use proxy_helpers::proxy_runner::{MixProxySender, ProxyRunner}; use service_providers_common::interface::RequestVersion; use socks5_requests::{ConnectionId, RemoteAddress, Socks5Request}; use std::io; -use task::TaskClient; use tokio::net::TcpStream; /// An outbound TCP connection between the Socks5 service provider, which makes