Mod to mixnet client mutability from traits elsewhere

This commit is contained in:
mfahampshire
2025-10-20 18:44:56 +01:00
parent 7105bbf4b4
commit 0208a84b77
8 changed files with 1020 additions and 14116 deletions
Generated
-13739
View File
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -143,9 +143,9 @@ members = [
"nym-statistics-api",
"nym-validator-rewarder",
"nyx-chain-watcher",
"sdk/ffi/cpp",
"sdk/ffi/go",
"sdk/ffi/shared",
# "sdk/ffi/cpp",
# "sdk/ffi/go",
# "sdk/ffi/shared",
"sdk/rust/nym-sdk",
"mixtcp",
# "service-providers/authenticator",
@@ -28,7 +28,7 @@ impl MixnetConnectionBeacon {
}
}
async fn send_mixnet_self_ping(&self) -> Result<u64> {
async fn send_mixnet_self_ping(&mut self) -> Result<u64> {
trace!("Sending mixnet self ping");
let (input_message, request_id) = create_self_ping(self.our_address);
self.mixnet_client_sender
@@ -38,7 +38,7 @@ impl MixnetConnectionBeacon {
Ok(request_id)
}
pub async fn run(self, shutdown: CancellationToken) -> Result<()> {
pub async fn run(mut self, shutdown: CancellationToken) -> Result<()> {
debug!("Mixnet connection beacon is running");
let mut ping_interval = tokio::time::interval(MIXNET_SELF_PING_INTERVAL);
loop {
@@ -22,23 +22,22 @@ pub async fn self_ping_and_wait(
wait_for_self_ping_return(mixnet_client, &request_ids).await
}
async fn send_self_pings(our_address: Recipient, mixnet_client: &MixnetClient) -> Result<Vec<u64>> {
// Send pings
let request_ids = futures::stream::iter(1..=3)
.then(|_| async {
let (input_message, request_id) = create_self_ping(our_address);
mixnet_client
.send(input_message)
.await
.map_err(|err| Error::NymSdkError(Box::new(err)))?;
Ok::<u64, Error>(request_id)
})
.collect::<Vec<_>>()
.await;
async fn send_self_pings(
our_address: Recipient,
mixnet_client: &mut MixnetClient,
) -> Result<Vec<u64>> {
let mut request_ids = Vec::with_capacity(3);
// Check the vec of results and return the first error, if any. If there are not errors, unwrap
// all the results into a vec of u64s.
request_ids.into_iter().collect::<Result<Vec<_>>>()
for _ in 1..=3 {
let (input_message, request_id) = create_self_ping(our_address);
mixnet_client
.send(input_message)
.await
.map_err(|err| Error::NymSdkError(Box::new(err)))?;
request_ids.push(request_id);
}
Ok(request_ids)
}
async fn wait_for_self_ping_return(
+2 -2
View File
@@ -20,7 +20,7 @@ pub fn icmp_identifier() -> u16 {
}
pub async fn send_ping_v4(
mixnet_client: &MixnetClient,
mixnet_client: &mut MixnetClient,
our_ips: IpPair,
sequence_number: u16,
destination: Ipv4Addr,
@@ -42,7 +42,7 @@ pub async fn send_ping_v4(
}
pub async fn send_ping_v6(
mixnet_client: &MixnetClient,
mixnet_client: &mut MixnetClient,
our_ips: IpPair,
sequence_number: u16,
destination: Ipv6Addr,
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -83,7 +83,7 @@ impl IprClientConnect {
self.listen_for_connect_response(request_id).await
}
async fn send_connect_request(&self, ip_packet_router_address: Recipient) -> Result<u64> {
async fn send_connect_request(&mut self, ip_packet_router_address: Recipient) -> Result<u64> {
let (request, request_id) = IpPacketRequest::new_connect_request(None);
// We use 20 surbs for the connect request because typically the IPR is configured to have
@@ -16,7 +16,7 @@ use nym_client_core::HardcodedTopologyProvider;
use nym_client_core::client::mix_traffic::transceiver::GatewayTransceiver;
use nym_client_core::config::disk_persistence::CommonClientPaths;
use nym_network_defaults::NymNetworkDetails;
use nym_sdk::mixnet::{MixnetMessageSender, TopologyProvider};
use nym_sdk::mixnet::TopologyProvider;
use nym_service_providers_common::ServiceProvider;
use nym_service_providers_common::interface::{
BinaryInformation, ProviderInterfaceVersion, Request, RequestVersion,