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