event_graph: DEP-0007: rename allowed_transports, retrieve outbound_connect_timeout from network profiles

This commit is contained in:
oars
2025-08-13 17:05:05 +03:00
parent ee33b9de3b
commit dc57ad3259
3 changed files with 32 additions and 16 deletions

View File

@@ -252,10 +252,14 @@ impl EventGraph {
continue
};
// Node waits for response
let Ok(peer_tips) = tip_rep_sub
.receive_with_timeout(self.p2p.settings().read().await.outbound_connect_timeout)
let outbound_connect_timeout = self
.p2p
.settings()
.read_arc()
.await
.outbound_connect_timeout(channel.address().scheme());
// Node waits for response
let Ok(peer_tips) = tip_rep_sub.receive_with_timeout(outbound_connect_timeout).await
else {
error!(
target: "event_graph::dag_sync()",
@@ -351,10 +355,14 @@ impl EventGraph {
continue
}
// Node waits for response
let Ok(parent) = ev_rep_sub
.receive_with_timeout(self.p2p.settings().read().await.outbound_connect_timeout)
let outbound_connect_timeout = self
.p2p
.settings()
.read_arc()
.await
.outbound_connect_timeout(channel.address().scheme());
// Node waits for response
let Ok(parent) = ev_rep_sub.receive_with_timeout(outbound_connect_timeout).await
else {
error!(
target: "event_graph::dag_sync()",

View File

@@ -339,13 +339,16 @@ impl ProtocolEventGraph {
.send(&EventReq(missing_parents.clone().into_iter().collect()))
.await?;
// Node waits for response
let Ok(parents) = self
.ev_rep_sub
.receive_with_timeout(
self.event_graph.p2p.settings().read().await.outbound_connect_timeout,
)
let outbound_connect_timeout = self
.event_graph
.p2p
.settings()
.read_arc()
.await
.outbound_connect_timeout(self.channel.address().scheme());
// Node waits for response
let Ok(parents) =
self.ev_rep_sub.receive_with_timeout(outbound_connect_timeout).await
else {
error!(
target: "event_graph::protocol::handle_event_put()",

View File

@@ -18,7 +18,7 @@
// cargo test --release --features=event-graph --lib eventgraph_propagation -- --include-ignored
use std::{slice, sync::Arc};
use std::{collections::HashMap, slice, sync::Arc};
use rand::{prelude::SliceRandom, rngs::ThreadRng};
use sled_overlay::sled;
@@ -31,7 +31,7 @@ use crate::{
proto::{EventPut, ProtocolEventGraph},
Event, EventGraph,
},
net::{session::SESSION_DEFAULT, P2p, Settings},
net::{session::SESSION_DEFAULT, settings::NetworkProfile, P2p, Settings},
system::sleep,
util::logger::{setup_test_logger, Level},
};
@@ -80,14 +80,19 @@ async fn spawn_node(
peers: Vec<Url>,
ex: Arc<Executor<'static>>,
) -> Arc<EventGraph> {
let mut profiles = HashMap::new();
profiles.insert(
"tcp".to_string(),
NetworkProfile { outbound_connect_timeout: 2, ..Default::default() },
);
let settings = Settings {
localnet: true,
inbound_addrs,
outbound_connections: 0,
outbound_connect_timeout: 2,
inbound_connections: usize::MAX,
peers,
allowed_transports: vec!["tcp".to_string()],
active_profiles: vec!["tcp".to_string()],
profiles,
..Default::default()
};