keepalive updates working correctly
This commit is contained in:
parent
1804c8e00c
commit
801d058682
@ -1,11 +1,11 @@
|
|||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
use crate::grpc::challenge::NodeUpdate;
|
use crate::grpc::challenge::NodeUpdate;
|
||||||
|
use chrono::{DateTime, Utc};
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
use dashmap::DashSet;
|
use dashmap::DashSet;
|
||||||
use solana_sdk::signature::keypair::Keypair;
|
use solana_sdk::signature::keypair::Keypair;
|
||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
use std::time::{Duration, UNIX_EPOCH};
|
use std::time::{Duration, UNIX_EPOCH};
|
||||||
use chrono::{DateTime, Utc};
|
|
||||||
|
|
||||||
type IP = String;
|
type IP = String;
|
||||||
pub const LOCALHOST: &str = "localhost";
|
pub const LOCALHOST: &str = "localhost";
|
||||||
@ -28,6 +28,7 @@ impl NodeInfo {
|
|||||||
|| self.ratls_attacks > other_node.ratls_attacks
|
|| self.ratls_attacks > other_node.ratls_attacks
|
||||||
|| self.ratls_conns > other_node.ratls_conns
|
|| self.ratls_conns > other_node.ratls_conns
|
||||||
|| self.mints > other_node.mints
|
|| self.mints > other_node.mints
|
||||||
|
|| (self.public && !other_node.public)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -94,9 +95,7 @@ impl Store {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn increase_mint_requests(&self) {
|
pub fn increase_mint_requests(&self) {
|
||||||
println!("increasing localhost");
|
|
||||||
if let Some(mut localhost_info) = self.nodes.get_mut(LOCALHOST) {
|
if let Some(mut localhost_info) = self.nodes.get_mut(LOCALHOST) {
|
||||||
println!("increasing localhost from {}", localhost_info.mint_requests);
|
|
||||||
localhost_info.mint_requests += 1;
|
localhost_info.mint_requests += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -137,7 +136,7 @@ impl Store {
|
|||||||
}
|
}
|
||||||
None => SystemTime::now(),
|
None => SystemTime::now(),
|
||||||
};
|
};
|
||||||
let node_info = NodeInfo {
|
let mut node_info = NodeInfo {
|
||||||
started_at,
|
started_at,
|
||||||
keepalive,
|
keepalive,
|
||||||
mint_requests: node.mint_requests,
|
mint_requests: node.mint_requests,
|
||||||
@ -150,6 +149,7 @@ impl Store {
|
|||||||
if !node_info.newer_than(&old_node) {
|
if !node_info.newer_than(&old_node) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
node_info.public = node_info.public || old_node.public;
|
||||||
}
|
}
|
||||||
self.nodes.insert(ip, node_info);
|
self.nodes.insert(ip, node_info);
|
||||||
true
|
true
|
||||||
@ -160,19 +160,19 @@ impl Store {
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|node| {
|
.map(|node| {
|
||||||
let joined_at: DateTime<Utc> = node.value().started_at.into();
|
let joined_at: DateTime<Utc> = node.value().started_at.into();
|
||||||
let last_keepalive: DateTime<Utc> = node.value().started_at.into();
|
let last_keepalive: DateTime<Utc> = node.value().keepalive.into();
|
||||||
let joined_at = joined_at.format("%Y-%m-%d %H:%M:%S").to_string();
|
let joined_at = joined_at.format("%Y-%m-%d %H:%M:%S").to_string();
|
||||||
let last_keepalive = last_keepalive.format("%Y-%m-%d %H:%M:%S").to_string();
|
let last_keepalive = last_keepalive.format("%Y-%m-%d %H:%M:%S").to_string();
|
||||||
crate::http_server::NodesResp {
|
crate::http_server::NodesResp {
|
||||||
ip: node.key().to_string(),
|
ip: node.key().to_string(),
|
||||||
joined_at,
|
joined_at,
|
||||||
last_keepalive,
|
last_keepalive,
|
||||||
mints: node.value().mints,
|
mints: node.value().mints,
|
||||||
ratls_connections: node.value().ratls_conns,
|
ratls_connections: node.value().ratls_conns,
|
||||||
ratls_attacks: node.value().ratls_attacks,
|
ratls_attacks: node.value().ratls_attacks,
|
||||||
public: node.value().public,
|
public: node.value().public,
|
||||||
mint_requests: node.value().mint_requests,
|
mint_requests: node.value().mint_requests,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user