From 68f0ff6afb8d8e9c7be61aa37850f6d6c2c9c835 Mon Sep 17 00:00:00 2001
From: Cyrix126 <58007246+Cyrix126@users.noreply.github.com>
Date: Tue, 31 Dec 2024 14:45:31 +0100
Subject: [PATCH] fix: handle case where zmq-last_active is not present

---
 src/helper/p2pool.rs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/helper/p2pool.rs b/src/helper/p2pool.rs
index 5242c55..26d8f5f 100644
--- a/src/helper/p2pool.rs
+++ b/src/helper/p2pool.rs
@@ -1044,7 +1044,7 @@ impl PubP2poolApi {
         *public = Self {
             p2p_connected: p2p.connections,
             // 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)
         };
     }
@@ -1358,7 +1358,7 @@ impl PoolStatistics {
 #[derive(Debug, Serialize, Deserialize, Clone)]
 pub(super) struct PrivP2PoolP2PApi {
     pub connections: u32,
-    pub zmq_last_active: u32,
+    pub zmq_last_active: Option<u32>,
 }
 
 impl Default for PrivP2PoolP2PApi {
@@ -1371,7 +1371,7 @@ impl PrivP2PoolP2PApi {
     fn new() -> Self {
         Self {
             connections: 0,
-            zmq_last_active: 0,
+            zmq_last_active: None,
         }
     }