From f3bb85508335eab91fbd76d15e74dcc575195acf Mon Sep 17 00:00:00 2001 From: hozan23 Date: Mon, 24 Jun 2024 19:26:26 +0200 Subject: p2p/backend: add methods to return inbound/outbound connected peers --- p2p/src/backend.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'p2p/src/backend.rs') diff --git a/p2p/src/backend.rs b/p2p/src/backend.rs index 16cc20b..f21d70b 100644 --- a/p2p/src/backend.rs +++ b/p2p/src/backend.rs @@ -1,8 +1,9 @@ -use std::sync::Arc; +use std::{collections::HashMap, sync::Arc}; use log::info; use karyon_core::{async_runtime::Executor, crypto::KeyPair}; +use karyon_net::Endpoint; use crate::{ config::Config, @@ -111,14 +112,14 @@ impl Backend { &self.key_pair } - /// Returns the number of occupied inbound slots. - pub fn inbound_slots(&self) -> usize { - self.discovery.inbound_slots.load() + /// Returns a map of inbound connected peers with their endpoints. + pub async fn inbound_peers(&self) -> HashMap { + self.peer_pool.inbound_peers().await } - /// Returns the number of occupied outbound slots. - pub fn outbound_slots(&self) -> usize { - self.discovery.outbound_slots.load() + /// Returns a map of outbound connected peers with their endpoints. + pub async fn outbound_peers(&self) -> HashMap { + self.peer_pool.outbound_peers().await } /// Returns the monitor to receive system events. -- cgit v1.2.3