fixed small errors in logic
small errors that were causing everything to crash
This commit is contained in:
parent
3e323cbd23
commit
e13fb05dbb
@ -174,7 +174,7 @@ impl Store {
|
||||
};
|
||||
if let Some(mut old_node_info) = self.update_node(node.ip, node_info.clone()).await {
|
||||
if !node_info.public {
|
||||
old_node_info.public = false;
|
||||
old_node_info.public = node_info.public;
|
||||
}
|
||||
match old_node_info.ne(&node_info) {
|
||||
true => {
|
||||
@ -191,8 +191,8 @@ impl Store {
|
||||
/// returns old pubkey if node got updated
|
||||
async fn update_node(&self, ip: String, info: NodeInfo) -> Option<NodeInfo> {
|
||||
if let Some(old_node) = self.nodes.get(&ip) {
|
||||
if old_node.updated_at > info.updated_at {
|
||||
return None;
|
||||
if old_node.updated_at >= info.updated_at {
|
||||
return Some(info);
|
||||
}
|
||||
}
|
||||
self.nodes.insert(ip, info.clone())
|
||||
|
@ -13,14 +13,15 @@ use tokio::time::{sleep, Duration};
|
||||
|
||||
async fn cycle_keys(ds: Arc<Store>, tx: Sender<NodeUpdate>) {
|
||||
loop {
|
||||
let _ = tx.send(ds.reset_localhost_keys().await);
|
||||
sleep(Duration::from_secs(60)).await;
|
||||
let _ = tx.send(ds.reset_localhost_keys().await);
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let ds: Arc<Store> = Arc::new(Store::init());
|
||||
ds.reset_localhost_keys().await;
|
||||
let (tx, mut _rx) = broadcast::channel(500);
|
||||
|
||||
let mut long_term_tasks = JoinSet::new();
|
||||
|
Loading…
Reference in New Issue
Block a user