diff --git a/src/clients/mod.rs b/src/clients/mod.rs index 39975b339b..dd818526df 100644 --- a/src/clients/mod.rs +++ b/src/clients/mod.rs @@ -130,14 +130,14 @@ impl NymClient { } async fn start_provider_polling(provider_address: SocketAddrV4) { - let provider_client = ProviderClient::new(); + let provider_client = ProviderClient::new(provider_address); loop { println!("[FETCH MSG] - Polling provider..."); let delay_duration = Duration::from_secs_f64(FETCH_MESSAGES_DELAY); tokio::time::delay_for(delay_duration).await; provider_client - .retrieve_messages(provider_address) + .retrieve_messages() .await .unwrap(); } @@ -146,6 +146,12 @@ impl NymClient { pub fn start(self, socket_address: SocketAddr) -> Result<(), Box> { println!("starting nym client"); + + // TODO: registration here + + return Ok(()); + // don't start anything, just register + let (mix_tx, mix_rx) = mpsc::unbounded(); let mut rt = Runtime::new()?; let topology = get_topology(self.is_local); diff --git a/src/clients/provider.rs b/src/clients/provider.rs index ff2fdb6bac..5991b42288 100644 --- a/src/clients/provider.rs +++ b/src/clients/provider.rs @@ -1,29 +1,33 @@ use sfw_provider_requests::requests::{ProviderRequest, PullRequest}; use sfw_provider_requests::responses::{ProviderResponse, PullResponse}; -use std::net::Shutdown; +use std::net::{Shutdown, SocketAddr}; use std::net::SocketAddrV4; use tokio::prelude::*; -use tokio::time::Duration; +use std::time::Duration; -pub struct ProviderClient {} +pub struct ProviderClient { + address: SocketAddrV4, +} impl ProviderClient { - pub fn new() -> Self { - ProviderClient {} + pub fn new(address: SocketAddrV4) -> Self { + ProviderClient { + address + } } pub async fn retrieve_messages( &self, - provider: SocketAddrV4, ) -> Result<(), Box> { - let address = [42; 32]; - let pull_request = PullRequest::new(address); + let destination_address = [42u8; 32]; + let dummy_auth_token_to_make_it_compile = [0u8; 32]; + let pull_request = PullRequest::new(destination_address, dummy_auth_token_to_make_it_compile); let bytes = pull_request.to_bytes(); // DH temporary: the provider's client port is not in the topology, but we can't change that // right now without messing up the existing Go mixnet. So I'm going to hardcode this // for the moment until the Go mixnet goes away. - let provider_socket = SocketAddrV4::new(*provider.ip(), 9000); + let provider_socket = SocketAddrV4::new(*self.address.ip(), 9000); println!("Provider: {:?}", provider_socket); let mut socket = tokio::net::TcpStream::connect(provider_socket).await?;