Mixnode no longer crashing when failed to send metrics or presence

This commit is contained in:
Jedrzej Stuczynski
2020-01-16 13:42:50 +00:00
parent 773fbceff7
commit 09e88da1a9
3 changed files with 16 additions and 12 deletions
+10 -8
View File
@@ -4,6 +4,7 @@ use directory_client::DirectoryClient;
use futures::channel::mpsc;
use futures::lock::Mutex;
use futures::StreamExt;
use log::{debug, error};
use std::collections::HashMap;
use std::sync::Arc;
use std::time::Duration;
@@ -80,14 +81,15 @@ impl MetricsReporter {
tokio::time::delay_for(delay_duration).await;
let (received, sent) =
MetricsReporter::acquire_and_reset_metrics(metrics.clone()).await;
directory_client
.metrics_post
.post(&MixMetric {
pub_key: pub_key_str.clone(),
received,
sent,
})
.unwrap();
match directory_client.metrics_post.post(&MixMetric {
pub_key: pub_key_str.clone(),
received,
sent,
}) {
Err(err) => error!("failed to send metrics - {:?}", err),
Ok(_) => debug!("sent metrics information"),
}
}
}
}
+5 -4
View File
@@ -2,6 +2,7 @@ use crate::node;
use directory_client::presence::MixNodePresence;
use directory_client::requests::presence_mixnodes_post::PresenceMixNodesPoster;
use directory_client::DirectoryClient;
use log::{debug, error};
use std::time::Duration;
pub struct Notifier {
@@ -29,10 +30,10 @@ impl Notifier {
}
pub fn notify(&self) {
self.net_client
.presence_mix_nodes_post
.post(&self.presence)
.unwrap();
match self.net_client.presence_mix_nodes_post.post(&self.presence) {
Err(err) => error!("failed to send presence - {:?}", err),
Ok(_) => debug!("sent presence information"),
}
}
pub async fn run(self) {