@@ -2056,16 +2056,48 @@ pub async fn handle_request(request: &str, state: Arc<RwLock<ServerState>>) -> R
20562056 log:: info!( "Getting current slot" ) ;
20572057 let params = req. params . unwrap_or_else ( || serde_json:: json!( { } ) ) ;
20582058 let state = state. read ( ) . await ;
2059- let result = if let Some ( commitment_str) = params. get ( "commitment" ) . and_then ( |v| v. as_str ( ) ) {
2060- let commitment = match commitment_str {
2061- "processed" => solana_sdk:: commitment_config:: CommitmentConfig :: processed ( ) ,
2062- "confirmed" => solana_sdk:: commitment_config:: CommitmentConfig :: confirmed ( ) ,
2063- "finalized" => solana_sdk:: commitment_config:: CommitmentConfig :: finalized ( ) ,
2064- _ => solana_sdk:: commitment_config:: CommitmentConfig :: finalized ( ) ,
2065- } ;
2066- crate :: rpc:: blocks:: get_slot_with_commitment ( & state. rpc_client , commitment) . await ?
2059+ let result = if is_multi_network_mode ( & state) {
2060+ // Multi-network mode
2061+ let mut network_results = serde_json:: Map :: new ( ) ;
2062+ for network_id in state. get_enabled_networks ( ) {
2063+ if let Some ( client) = state. svm_clients . get ( network_id) {
2064+ let slot_result = if let Some ( commitment_str) = params. get ( "commitment" ) . and_then ( |v| v. as_str ( ) ) {
2065+ let commitment = match commitment_str {
2066+ "processed" => solana_sdk:: commitment_config:: CommitmentConfig :: processed ( ) ,
2067+ "confirmed" => solana_sdk:: commitment_config:: CommitmentConfig :: confirmed ( ) ,
2068+ "finalized" => solana_sdk:: commitment_config:: CommitmentConfig :: finalized ( ) ,
2069+ _ => solana_sdk:: commitment_config:: CommitmentConfig :: finalized ( ) ,
2070+ } ;
2071+ crate :: rpc:: blocks:: get_slot_with_commitment ( client, commitment) . await
2072+ } else {
2073+ crate :: rpc:: blocks:: get_slot ( client) . await
2074+ } ;
2075+ match slot_result {
2076+ Ok ( result) => {
2077+ network_results. insert ( network_id. to_string ( ) , result) ;
2078+ }
2079+ Err ( e) => {
2080+ network_results. insert ( network_id. to_string ( ) , serde_json:: json!( {
2081+ "error" : e. to_string( )
2082+ } ) ) ;
2083+ }
2084+ }
2085+ }
2086+ }
2087+ serde_json:: Value :: Object ( network_results)
20672088 } else {
2068- crate :: rpc:: blocks:: get_slot ( & state. rpc_client ) . await ?
2089+ // Single network mode
2090+ if let Some ( commitment_str) = params. get ( "commitment" ) . and_then ( |v| v. as_str ( ) ) {
2091+ let commitment = match commitment_str {
2092+ "processed" => solana_sdk:: commitment_config:: CommitmentConfig :: processed ( ) ,
2093+ "confirmed" => solana_sdk:: commitment_config:: CommitmentConfig :: confirmed ( ) ,
2094+ "finalized" => solana_sdk:: commitment_config:: CommitmentConfig :: finalized ( ) ,
2095+ _ => solana_sdk:: commitment_config:: CommitmentConfig :: finalized ( ) ,
2096+ } ;
2097+ crate :: rpc:: blocks:: get_slot_with_commitment ( & state. rpc_client , commitment) . await ?
2098+ } else {
2099+ crate :: rpc:: blocks:: get_slot ( & state. rpc_client ) . await ?
2100+ }
20692101 } ;
20702102 Ok ( create_success_response ( result, req. id ) )
20712103 } ,
@@ -2515,16 +2547,48 @@ pub async fn handle_request(request: &str, state: Arc<RwLock<ServerState>>) -> R
25152547 log:: info!( "Getting transaction count" ) ;
25162548 let params = req. params . unwrap_or_else ( || serde_json:: json!( { } ) ) ;
25172549 let state = state. read ( ) . await ;
2518- let result = if let Some ( commitment_str) = params. get ( "commitment" ) . and_then ( |v| v. as_str ( ) ) {
2519- let commitment = match commitment_str {
2520- "processed" => solana_sdk:: commitment_config:: CommitmentConfig :: processed ( ) ,
2521- "confirmed" => solana_sdk:: commitment_config:: CommitmentConfig :: confirmed ( ) ,
2522- "finalized" => solana_sdk:: commitment_config:: CommitmentConfig :: finalized ( ) ,
2523- _ => solana_sdk:: commitment_config:: CommitmentConfig :: finalized ( ) ,
2524- } ;
2525- crate :: rpc:: system:: get_transaction_count_with_commitment ( & state. rpc_client , commitment) . await ?
2550+ let result = if is_multi_network_mode ( & state) {
2551+ // Multi-network mode
2552+ let mut network_results = serde_json:: Map :: new ( ) ;
2553+ for network_id in state. get_enabled_networks ( ) {
2554+ if let Some ( client) = state. svm_clients . get ( network_id) {
2555+ let count_result = if let Some ( commitment_str) = params. get ( "commitment" ) . and_then ( |v| v. as_str ( ) ) {
2556+ let commitment = match commitment_str {
2557+ "processed" => solana_sdk:: commitment_config:: CommitmentConfig :: processed ( ) ,
2558+ "confirmed" => solana_sdk:: commitment_config:: CommitmentConfig :: confirmed ( ) ,
2559+ "finalized" => solana_sdk:: commitment_config:: CommitmentConfig :: finalized ( ) ,
2560+ _ => solana_sdk:: commitment_config:: CommitmentConfig :: finalized ( ) ,
2561+ } ;
2562+ crate :: rpc:: system:: get_transaction_count_with_commitment ( client, commitment) . await
2563+ } else {
2564+ crate :: rpc:: system:: get_transaction_count ( client) . await
2565+ } ;
2566+ match count_result {
2567+ Ok ( result) => {
2568+ network_results. insert ( network_id. to_string ( ) , result) ;
2569+ }
2570+ Err ( e) => {
2571+ network_results. insert ( network_id. to_string ( ) , serde_json:: json!( {
2572+ "error" : e. to_string( )
2573+ } ) ) ;
2574+ }
2575+ }
2576+ }
2577+ }
2578+ serde_json:: Value :: Object ( network_results)
25262579 } else {
2527- crate :: rpc:: system:: get_transaction_count ( & state. rpc_client ) . await ?
2580+ // Single network mode
2581+ if let Some ( commitment_str) = params. get ( "commitment" ) . and_then ( |v| v. as_str ( ) ) {
2582+ let commitment = match commitment_str {
2583+ "processed" => solana_sdk:: commitment_config:: CommitmentConfig :: processed ( ) ,
2584+ "confirmed" => solana_sdk:: commitment_config:: CommitmentConfig :: confirmed ( ) ,
2585+ "finalized" => solana_sdk:: commitment_config:: CommitmentConfig :: finalized ( ) ,
2586+ _ => solana_sdk:: commitment_config:: CommitmentConfig :: finalized ( ) ,
2587+ } ;
2588+ crate :: rpc:: system:: get_transaction_count_with_commitment ( & state. rpc_client , commitment) . await ?
2589+ } else {
2590+ crate :: rpc:: system:: get_transaction_count ( & state. rpc_client ) . await ?
2591+ }
25282592 } ;
25292593 Ok ( create_success_response ( result, req. id ) )
25302594 } ,
0 commit comments