The credential issuance and verification handlers used Handle::block_on() directly inside the tokio runtime, causing a deadlock. Wrapped with block_in_place() to properly yield the runtime thread. Also completed full feature verification across all 25 test groups (~175 checks) on live server. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
46 lines
1.6 KiB
Rust
46 lines
1.6 KiB
Rust
use super::RpcHandler;
|
|
use crate::network::dwn_sync;
|
|
use crate::peers;
|
|
use anyhow::Result;
|
|
|
|
impl RpcHandler {
|
|
/// Get DWN status and sync state.
|
|
pub(super) async fn handle_dwn_status(&self) -> Result<serde_json::Value> {
|
|
let sync_state = dwn_sync::load_sync_state(&self.config.data_dir).await?;
|
|
let server_status = dwn_sync::get_dwn_status().await.unwrap_or(dwn_sync::DwnStatusResponse {
|
|
running: false,
|
|
version: String::new(),
|
|
});
|
|
|
|
Ok(serde_json::json!({
|
|
"running": server_status.running,
|
|
"version": server_status.version,
|
|
"sync_status": sync_state.status,
|
|
"last_sync": sync_state.last_sync,
|
|
"messages_synced": sync_state.messages_synced,
|
|
"storage_bytes": sync_state.storage_bytes,
|
|
"registered_protocols": sync_state.registered_protocols,
|
|
"peer_sync_targets": sync_state.peer_sync_targets,
|
|
}))
|
|
}
|
|
|
|
/// Trigger DWN sync with connected peers.
|
|
pub(super) async fn handle_dwn_sync(&self) -> Result<serde_json::Value> {
|
|
// Get list of connected peers' onion addresses
|
|
let peer_list = peers::load_peers(&self.config.data_dir).await?;
|
|
let onions: Vec<String> = peer_list
|
|
.iter()
|
|
.filter(|p| !p.onion.is_empty())
|
|
.map(|p| p.onion.clone())
|
|
.collect();
|
|
|
|
let state = dwn_sync::sync_with_peers(&self.config.data_dir, &onions).await?;
|
|
|
|
Ok(serde_json::json!({
|
|
"sync_status": state.status,
|
|
"last_sync": state.last_sync,
|
|
"messages_synced": state.messages_synced,
|
|
}))
|
|
}
|
|
}
|