mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 11:27:58 +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:
@@ -240,6 +240,20 @@ impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> Protocol<B, S, H> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn peers(&self) -> Vec<(NodeIndex, PeerInfo<B>)> {
|
||||
self.context_data.peers.read().iter().map(|(idx, p)| {
|
||||
(
|
||||
*idx,
|
||||
PeerInfo {
|
||||
roles: p.roles,
|
||||
protocol_version: p.protocol_version,
|
||||
best_hash: p.best_hash,
|
||||
best_number: p.best_number,
|
||||
}
|
||||
)
|
||||
}).collect()
|
||||
}
|
||||
|
||||
pub fn handle_packet(&self, io: &mut SyncIo, who: NodeIndex, mut data: &[u8]) {
|
||||
let message: Message<B> = match Decode::decode(&mut data) {
|
||||
Some(m) => m,
|
||||
|
||||
Reference in New Issue
Block a user