@@ -5,6 +5,7 @@ use crate::grpc_client;
55use std:: sync:: { Arc , RwLock } ;
66use std:: time:: { Duration , Instant } ;
77use tokio:: sync:: Mutex ;
8+ use chrono:: Local ;
89
910pub struct MasternodeCache {
1011 data : Arc < RwLock < Option < EvoMasternodeList > > > ,
@@ -72,21 +73,28 @@ impl MasternodeCache {
7273 async move {
7374 // Skip POSE_BANNED nodes
7475 if status == "POSE_BANNED" {
76+ println ! ( "⏭️ Node {} at {} - skipping (POSE_BANNED)" , idx, address) ;
7577 return ( idx, "fail" . to_string ( ) , None , None ) ;
7678 }
7779
7880 // Parse address to get IP and port
7981 let parts: Vec < & str > = address. split ( ':' ) . collect ( ) ;
8082 if parts. len ( ) != 2 {
83+ println ! ( "❌ Node {} at {} - invalid address format" , idx, address) ;
8184 return ( idx, "fail" . to_string ( ) , None , None ) ;
8285 }
8386
8487 let ip = parts[ 0 ] ;
85- let port = 1443u16 ; // Platform gRPC port is always 1443
88+ let port = self . config . get_dapi_port ( ) ;
8689
87- // Check version with timeout
88- match grpc_client:: check_node_version ( ip, port) . await {
89- Ok ( result) => {
90+ println ! ( "🔍 Node {} at {} - checking version..." , idx, address) ;
91+
92+ // Check version with additional timeout wrapper (3 seconds total)
93+ match tokio:: time:: timeout (
94+ tokio:: time:: Duration :: from_secs ( 3 ) ,
95+ grpc_client:: check_node_version ( ip, port)
96+ ) . await {
97+ Ok ( Ok ( result) ) => {
9098 if result. success {
9199 println ! ( "✓ Node {} at {} - version 2.0+ (DAPI: {:?}, Drive: {:?})" ,
92100 idx, address, result. dapi_version, result. drive_version) ;
@@ -97,10 +105,14 @@ impl MasternodeCache {
97105 ( idx, "fail" . to_string ( ) , result. dapi_version , result. drive_version )
98106 }
99107 } ,
100- Err ( e) => {
108+ Ok ( Err ( e) ) => {
101109 println ! ( "✗ Node {} at {} - error: {}" , idx, address, e) ;
102110 ( idx, "fail" . to_string ( ) , None , None )
103111 } ,
112+ Err ( _) => {
113+ println ! ( "✗ Node {} at {} - timeout after 3 seconds" , idx, address) ;
114+ ( idx, "fail" . to_string ( ) , None , None )
115+ } ,
104116 }
105117 }
106118 } ) . collect ( ) ;
@@ -140,8 +152,11 @@ impl MasternodeCache {
140152 tokio:: spawn ( async move {
141153 loop {
142154 tokio:: time:: sleep ( self . update_interval ) . await ;
143- if let Err ( e) = self . update_cache ( ) . await {
144- eprintln ! ( "Failed to update masternode cache: {}" , e) ;
155+ let now = Local :: now ( ) ;
156+ println ! ( "🔄 [{}] Background refresh: Starting masternode cache update..." , now. format( "%Y-%m-%d %H:%M:%S" ) ) ;
157+ match self . update_cache ( ) . await {
158+ Ok ( _) => println ! ( "✅ [{}] Background refresh: Masternode cache updated successfully" , Local :: now( ) . format( "%Y-%m-%d %H:%M:%S" ) ) ,
159+ Err ( e) => eprintln ! ( "❌ [{}] Background refresh: Failed to update masternode cache: {}" , Local :: now( ) . format( "%Y-%m-%d %H:%M:%S" ) , e) ,
145160 }
146161 }
147162 } ) ;
0 commit comments