Method to update auth token of provider client + removed mut from register

This commit is contained in:
Jedrzej Stuczynski
2019-12-18 11:22:46 +00:00
parent 2b89be3031
commit 0fe7276d44
+5 -1
View File
@@ -57,6 +57,10 @@ impl ProviderClient {
}
}
pub fn update_token(&mut self, auth_token: AuthToken) {
self.auth_token = Some(auth_token)
}
pub async fn send_request(&self, bytes: Vec<u8>) -> Result<Vec<u8>, ProviderClientError> {
let mut socket = tokio::net::TcpStream::connect(self.provider_network_address).await?;
println!("keep alive: {:?}", socket.keepalive());
@@ -99,7 +103,7 @@ impl ProviderClient {
Ok(())
}
pub async fn register(&mut self) -> Result<AuthToken, ProviderClientError> {
pub async fn register(&self) -> Result<AuthToken, ProviderClientError> {
if self.auth_token.is_some() {
return Err(ProviderClientError::ClientAlreadyRegisteredError);
}