fix: handle case where zmq-last_active is not present

This commit is contained in:
Cyrix126 2024-12-31 14:45:31 +01:00
parent ee2f27c5da
commit 0732bab78a

View file

@ -1044,7 +1044,7 @@ impl PubP2poolApi {
*public = Self { *public = Self {
p2p_connected: p2p.connections, p2p_connected: p2p.connections,
// 30 seconds before concluding the monero node connection is lost // 30 seconds before concluding the monero node connection is lost
node_connected: p2p.zmq_last_active < 30, node_connected: p2p.zmq_last_active.is_some_and(|x| x < 30),
..std::mem::take(&mut *public) ..std::mem::take(&mut *public)
}; };
} }
@ -1358,7 +1358,7 @@ impl PoolStatistics {
#[derive(Debug, Serialize, Deserialize, Clone)] #[derive(Debug, Serialize, Deserialize, Clone)]
pub(super) struct PrivP2PoolP2PApi { pub(super) struct PrivP2PoolP2PApi {
pub connections: u32, pub connections: u32,
pub zmq_last_active: u32, pub zmq_last_active: Option<u32>,
} }
impl Default for PrivP2PoolP2PApi { impl Default for PrivP2PoolP2PApi {
@ -1371,7 +1371,7 @@ impl PrivP2PoolP2PApi {
fn new() -> Self { fn new() -> Self {
Self { Self {
connections: 0, connections: 0,
zmq_last_active: 0, zmq_last_active: None,
} }
} }