aboutsummaryrefslogtreecommitdiff
path: root/p2p/src/discovery
diff options
context:
space:
mode:
authorhozan23 <hozan23@karyontech.net>2024-06-24 19:26:26 +0200
committerhozan23 <hozan23@karyontech.net>2024-06-24 19:26:26 +0200
commitf3bb85508335eab91fbd76d15e74dcc575195acf (patch)
treecddf1241f12763327a5d9e8365424d8fac52e82c /p2p/src/discovery
parentcc6b474b0d35f5fa3f00a742b1c0e18a9a1a25a3 (diff)
p2p/backend: add methods to return inbound/outbound connected peers
Diffstat (limited to 'p2p/src/discovery')
-rw-r--r--p2p/src/discovery/mod.rs35
1 files changed, 16 insertions, 19 deletions
diff --git a/p2p/src/discovery/mod.rs b/p2p/src/discovery/mod.rs
index 529469e..99f880d 100644
--- a/p2p/src/discovery/mod.rs
+++ b/p2p/src/discovery/mod.rs
@@ -53,12 +53,6 @@ pub struct Discovery {
/// Connection queue
conn_queue: Arc<ConnQueue>,
- /// Inbound slots.
- pub(crate) inbound_slots: Arc<ConnectionSlots>,
-
- /// Outbound slots.
- pub(crate) outbound_slots: Arc<ConnectionSlots>,
-
/// Managing spawned tasks.
task_group: TaskGroup,
@@ -76,23 +70,25 @@ impl Discovery {
monitor: Arc<Monitor>,
ex: Executor,
) -> ArcDiscovery {
- let inbound_slots = Arc::new(ConnectionSlots::new(config.inbound_slots));
- let outbound_slots = Arc::new(ConnectionSlots::new(config.outbound_slots));
+ let table = Arc::new(RoutingTable::new(peer_id.0));
- let table_key = peer_id.0;
- let table = Arc::new(RoutingTable::new(table_key));
+ let refresh_service = Arc::new(RefreshService::new(
+ config.clone(),
+ table.clone(),
+ monitor.clone(),
+ ex.clone(),
+ ));
- let refresh_service =
- RefreshService::new(config.clone(), table.clone(), monitor.clone(), ex.clone());
- let lookup_service = LookupService::new(
+ let lookup_service = Arc::new(LookupService::new(
key_pair,
peer_id,
table.clone(),
config.clone(),
monitor.clone(),
ex.clone(),
- );
+ ));
+ let outbound_slots = Arc::new(ConnectionSlots::new(config.outbound_slots));
let connector = Connector::new(
key_pair,
config.max_connect_retries,
@@ -102,6 +98,7 @@ impl Discovery {
ex.clone(),
);
+ let inbound_slots = Arc::new(ConnectionSlots::new(config.inbound_slots));
let listener = Listener::new(
key_pair,
inbound_slots.clone(),
@@ -110,16 +107,16 @@ impl Discovery {
ex.clone(),
);
+ let task_group = TaskGroup::with_executor(ex);
+
Arc::new(Self {
- refresh_service: Arc::new(refresh_service),
- lookup_service: Arc::new(lookup_service),
+ refresh_service,
+ lookup_service,
conn_queue,
table,
- inbound_slots,
- outbound_slots,
connector,
listener,
- task_group: TaskGroup::with_executor(ex),
+ task_group,
config,
})
}