LES Peer Info (#4195)
* connected peers function for network service * get LES peer info in sync API * new peer info in RPC
This commit is contained in:
committed by
Arkadiy Paronyan
parent
35666f718b
commit
3ff9324ec0
@@ -542,6 +542,20 @@ impl Host {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Get all connected peers.
|
||||
pub fn connected_peers(&self) -> Vec<PeerId> {
|
||||
let sessions = self.sessions.read();
|
||||
let sessions = &*sessions;
|
||||
|
||||
let mut peers = Vec::with_capacity(sessions.count());
|
||||
for i in (0..MAX_SESSIONS).map(|x| x + FIRST_SESSION) {
|
||||
if sessions.get(i).is_some() {
|
||||
peers.push(i);
|
||||
}
|
||||
}
|
||||
peers
|
||||
}
|
||||
|
||||
fn init_public_interface(&self, io: &IoContext<NetworkIoMessage>) -> Result<(), NetworkError> {
|
||||
if self.info.read().public_endpoint.is_some() {
|
||||
return Ok(());
|
||||
|
||||
Reference in New Issue
Block a user