Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
clap = { features = ["derive"], workspace = true }
codec.workspace = true
async-trait.workspace = true
frame-benchmarking-cli = { workspace = true, default-features = true, optional = true }
frame-metadata-hash-extension.default-features = true
frame-metadata-hash-extension.workspace = true
Expand Down
21 changes: 11 additions & 10 deletions node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

use std::sync::Arc;

use async_trait::async_trait;
use jsonrpsee::{core::RpcResult, proc_macros::rpc, RpcModule};
use quantus_runtime::{opaque::Block, AccountId, Balance, Nonce};
use sc_network::service::traits::NetworkService;
Expand Down Expand Up @@ -36,7 +37,7 @@ pub struct PeerInfo {
pub trait PeerApi {
/// Get basic peer information
#[method(name = "peer_getBasicInfo")]
fn get_basic_info(&self) -> RpcResult<PeerInfo>;
async fn get_basic_info(&self) -> RpcResult<PeerInfo>;
}

/// Peer RPC implementation
Expand All @@ -52,17 +53,17 @@ impl Peer {
}
}

#[async_trait]
impl PeerApiServer for Peer {
fn get_basic_info(&self) -> RpcResult<PeerInfo> {
async fn get_basic_info(&self) -> RpcResult<PeerInfo> {
if let Some(network) = &self.network {
let network_state =
futures::executor::block_on(network.network_state()).map_err(|_| {
jsonrpsee::types::error::ErrorObject::owned(
5001,
"Failed to get network state",
None::<()>,
)
})?;
let network_state = network.network_state().await.map_err(|_| {
jsonrpsee::types::error::ErrorObject::owned(
5001,
"Failed to get network state",
None::<()>,
)
})?;

let connected_peers: Vec<String> =
network_state.connected_peers.keys().cloned().collect();
Expand Down