@@ -59,7 +59,12 @@ pub fn continously_monitor_photon(
59
59
let mut has_been_healthy = false ;
60
60
start_latest_slot_updater ( rpc_client. clone ( ) ) . await ;
61
61
62
+ // Use interval timer to ensure fixed intervals regardless of execution time
63
+ let mut interval = interval ( Duration :: from_millis ( 5000 ) ) ;
64
+
62
65
loop {
66
+ interval. tick ( ) . await ;
67
+
63
68
let latest_slot = LATEST_SLOT . load ( Ordering :: SeqCst ) ;
64
69
let last_indexed_slot = fetch_last_indexed_slot_with_infinite_retry ( db. as_ref ( ) ) . await ;
65
70
let lag = if latest_slot > last_indexed_slot {
@@ -79,23 +84,43 @@ pub fn continously_monitor_photon(
79
84
error ! ( "Indexing lag is too high: {}" , lag) ;
80
85
}
81
86
} else {
82
- let tree_roots = load_db_tree_roots_with_infinite_retry ( db. as_ref ( ) ) . await ;
83
- validate_tree_roots ( rpc_client. as_ref ( ) , tree_roots ) . await ;
87
+ let db_clone = db. clone ( ) ;
88
+ let rpc_clone = rpc_client. clone ( ) ;
84
89
90
+ tokio:: spawn ( async move {
91
+ let tree_roots =
92
+ load_db_tree_roots_with_infinite_retry ( db_clone. as_ref ( ) ) . await ;
93
+ validate_tree_roots ( rpc_clone. as_ref ( ) , tree_roots) . await ;
94
+ } ) ;
95
+
96
+ // Spawn parallel verification tasks for each V2 tree
85
97
let v2_trees = queue_monitor:: collect_v2_trees ( ) . await ;
86
- if !v2_trees. is_empty ( ) {
87
- if let Err ( divergences) =
88
- queue_monitor:: verify_queues ( rpc_client. as_ref ( ) , db. as_ref ( ) , v2_trees)
98
+ for ( tree_pubkey, queue_type) in v2_trees {
99
+ let db_clone = db. clone ( ) ;
100
+ let rpc_clone = rpc_client. clone ( ) ;
101
+
102
+ tokio:: spawn ( async move {
103
+ if let Err ( divergences) = queue_monitor:: verify_single_queue (
104
+ rpc_clone. as_ref ( ) ,
105
+ db_clone. as_ref ( ) ,
106
+ tree_pubkey,
107
+ queue_type,
108
+ )
89
109
. await
90
110
{
111
+ if !divergences. is_empty ( ) {
112
+ for divergence in & divergences {
113
+ queue_monitor:: log_divergence ( divergence) ;
114
+ }
91
115
error ! (
92
- "V2 queue verification failed with {} divergences",
93
- divergences. len( )
116
+ "Queue verification failed for tree {} type {:?} with {} divergences",
117
+ tree_pubkey , queue_type , divergences. len( )
94
118
) ;
95
119
}
96
120
}
121
+ } ) ;
122
+ }
97
123
}
98
- sleep ( Duration :: from_millis ( 5000 ) ) . await ;
99
124
}
100
125
} )
101
126
}
0 commit comments