mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 02:07:56 +00:00
expose peer information via rpc (#1362)
* expose peer information via rpc * fixes tests * cleanup Co-Authored-By: xlc <xlchen1291@gmail.com> * Update docs Co-Authored-By: xlc <xlchen1291@gmail.com> * Add missing docs * keep original type for PeerInfo best_hash/best_number * cleanup * Update mod.rs
This commit is contained in:
@@ -16,8 +16,10 @@
|
||||
|
||||
use super::*;
|
||||
|
||||
use network::{self, SyncState, SyncStatus, ProtocolStatus};
|
||||
use network::{self, SyncState, SyncStatus, ProtocolStatus, NodeIndex, PeerId, PeerInfo as NetworkPeerInfo, PublicKey};
|
||||
use network::config::Roles;
|
||||
use test_client::runtime::Block;
|
||||
use primitives::H256;
|
||||
|
||||
#[derive(Default)]
|
||||
struct Status {
|
||||
@@ -37,6 +39,15 @@ impl network::SyncProvider<Block> for Status {
|
||||
num_active_peers: 0,
|
||||
}
|
||||
}
|
||||
|
||||
fn peers(&self) -> Vec<(NodeIndex, Option<PeerId>, NetworkPeerInfo<Block>)> {
|
||||
vec![(1, Some(PublicKey::Ed25519((0 .. 32).collect::<Vec<u8>>()).into()), NetworkPeerInfo {
|
||||
roles: Roles::FULL,
|
||||
protocol_version: 1,
|
||||
best_hash: Default::default(),
|
||||
best_number: 1
|
||||
})]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -129,3 +140,18 @@ fn system_health() {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn system_peers() {
|
||||
assert_eq!(
|
||||
api(None).system_peers().unwrap(),
|
||||
vec![PeerInfo {
|
||||
index: 1,
|
||||
peer_id: "QmS5oyTmdjwBowwAH1D9YQnoe2HyWpVemH8qHiU5RqWPh4".into(),
|
||||
roles: "FULL".into(),
|
||||
protocol_version: 1,
|
||||
best_hash: Default::default(),
|
||||
best_number: 1u64,
|
||||
}]
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user