aboutsummaryrefslogtreecommitdiff
path: root/p2p/src/discovery
diff options
context:
space:
mode:
authorhozan23 <hozan23@proton.me>2024-03-20 15:20:21 +0100
committerhozan23 <hozan23@proton.me>2024-03-20 15:20:21 +0100
commit379dca552ca91d22ee007b42f93803ad3dc2b274 (patch)
tree1ba10573b6ec5213baf46f6ab9c3767e0daa4eed /p2p/src/discovery
parent340957fec147f4429796413f27bbd9b84ba6f141 (diff)
core: add the option to create a new task group without providing an
executor & remove GlobalExecutor type
Diffstat (limited to 'p2p/src/discovery')
-rw-r--r--p2p/src/discovery/lookup.rs8
-rw-r--r--p2p/src/discovery/mod.rs5
-rw-r--r--p2p/src/discovery/refresh.rs7
3 files changed, 11 insertions, 9 deletions
diff --git a/p2p/src/discovery/lookup.rs b/p2p/src/discovery/lookup.rs
index 1d73306..c81fbc6 100644
--- a/p2p/src/discovery/lookup.rs
+++ b/p2p/src/discovery/lookup.rs
@@ -5,7 +5,11 @@ use log::{error, trace};
use rand::{rngs::OsRng, seq::SliceRandom, RngCore};
use smol::lock::{Mutex, RwLock};
-use karyon_core::{async_util::timeout, crypto::KeyPair, util::decode, GlobalExecutor};
+use karyon_core::{
+ async_util::{timeout, Executor},
+ crypto::KeyPair,
+ util::decode,
+};
use karyon_net::{Conn, Endpoint};
@@ -60,7 +64,7 @@ impl LookupService {
table: Arc<Mutex<RoutingTable>>,
config: Arc<Config>,
monitor: Arc<Monitor>,
- ex: GlobalExecutor,
+ ex: Executor<'static>,
) -> Self {
let inbound_slots = Arc::new(ConnectionSlots::new(config.lookup_inbound_slots));
let outbound_slots = Arc::new(ConnectionSlots::new(config.lookup_outbound_slots));
diff --git a/p2p/src/discovery/mod.rs b/p2p/src/discovery/mod.rs
index 040a415..4b54233 100644
--- a/p2p/src/discovery/mod.rs
+++ b/p2p/src/discovery/mod.rs
@@ -8,9 +8,8 @@ use rand::{rngs::OsRng, seq::SliceRandom};
use smol::lock::Mutex;
use karyon_core::{
- async_util::{Backoff, TaskGroup, TaskResult},
+ async_util::{Backoff, Executor, TaskGroup, TaskResult},
crypto::KeyPair,
- GlobalExecutor,
};
use karyon_net::{Conn, Endpoint};
@@ -72,7 +71,7 @@ impl Discovery {
conn_queue: Arc<ConnQueue>,
config: Arc<Config>,
monitor: Arc<Monitor>,
- ex: GlobalExecutor,
+ ex: Executor<'static>,
) -> ArcDiscovery {
let inbound_slots = Arc::new(ConnectionSlots::new(config.inbound_slots));
let outbound_slots = Arc::new(ConnectionSlots::new(config.outbound_slots));
diff --git a/p2p/src/discovery/refresh.rs b/p2p/src/discovery/refresh.rs
index bfcab56..e56f0eb 100644
--- a/p2p/src/discovery/refresh.rs
+++ b/p2p/src/discovery/refresh.rs
@@ -10,9 +10,8 @@ use smol::{
};
use karyon_core::{
- async_util::{timeout, Backoff, TaskGroup, TaskResult},
+ async_util::{timeout, Backoff, Executor, TaskGroup, TaskResult},
util::{decode, encode},
- GlobalExecutor,
};
use karyon_net::{udp, Connection, Endpoint, NetError};
@@ -46,7 +45,7 @@ pub struct RefreshService {
task_group: TaskGroup<'static>,
/// A global executor
- executor: GlobalExecutor,
+ executor: Executor<'static>,
/// Holds the configuration for the P2P network.
config: Arc<Config>,
@@ -61,7 +60,7 @@ impl RefreshService {
config: Arc<Config>,
table: Arc<Mutex<RoutingTable>>,
monitor: Arc<Monitor>,
- executor: GlobalExecutor,
+ executor: Executor<'static>,
) -> Self {
let listen_endpoint = config
.listen_endpoint