Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[comms] Connection manager requester not exposed on CommsNode #2815

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions base_layer/wallet/src/testnet_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,14 +319,14 @@ pub async fn generate_wallet_test_data<

wallet
.comms
.connection_manager()
.connectivity()
.dial_peer(wallet_alice.comms.node_identity().node_id().clone())
.await
.unwrap();

wallet
.comms
.connection_manager()
.connectivity()
.dial_peer(wallet_bob.comms.node_identity().node_id().clone())
.await
.unwrap();
Expand Down
6 changes: 3 additions & 3 deletions base_layer/wallet/tests/transaction_service/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ fn manage_single_transaction() {

let _ = runtime.block_on(
bob_comms
.connection_manager()
.connectivity()
.dial_peer(alice_node_identity.node_id().clone()),
);

Expand Down Expand Up @@ -765,15 +765,15 @@ fn manage_multiple_transactions() {

let _ = runtime.block_on(
bob_comms
.connection_manager()
.connectivity()
.dial_peer(alice_node_identity.node_id().clone()),
);
runtime.block_on(async { delay_for(Duration::from_secs(3)).await });

// Connect alice to carol
let _ = runtime.block_on(
alice_comms
.connection_manager()
.connectivity()
.dial_peer(carol_node_identity.node_id().clone()),
);

Expand Down
3 changes: 1 addition & 2 deletions comms/dht/examples/memory_net/utilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use std::{
};
use tari_comms::{
backoff::ConstantBackoff,
connection_manager::ConnectionDirection,
connection_manager::{ConnectionDirection, ConnectionManagerEvent},
connectivity::ConnectivitySelection,
peer_manager::{NodeId, NodeIdentity, Peer, PeerFeatures, PeerStorage},
pipeline,
Expand All @@ -46,7 +46,6 @@ use tari_comms::{
types::CommsDatabase,
CommsBuilder,
CommsNode,
ConnectionManagerEvent,
PeerConnection,
};
use tari_comms_dht::{
Expand Down
3 changes: 0 additions & 3 deletions comms/dht/src/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ use futures::{
use log::*;
use std::{cmp, fmt, fmt::Display, sync::Arc};
use tari_comms::{
connection_manager::ConnectionManagerError,
connectivity::{ConnectivityError, ConnectivityRequester, ConnectivitySelection},
peer_manager::{NodeId, NodeIdentity, PeerFeatures, PeerManager, PeerManagerError, PeerQuery, PeerQuerySortBy},
};
Expand Down Expand Up @@ -79,8 +78,6 @@ pub enum DhtActorError {
StoredValueFailedToDeserialize(MessageFormatError),
#[error("FailedToSerializeValue: {0}")]
FailedToSerializeValue(MessageFormatError),
#[error("ConnectionManagerError: {0}")]
ConnectionManagerError(#[from] ConnectionManagerError),
#[error("ConnectivityError: {0}")]
ConnectivityError(#[from] ConnectivityError),
#[error("Connectivity event stream closed")]
Expand Down
4 changes: 1 addition & 3 deletions comms/dht/src/discovery/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

use crate::outbound::{message::SendFailure, DhtOutboundError};
use futures::channel::mpsc::SendError;
use tari_comms::{connection_manager::ConnectionManagerError, peer_manager::PeerManagerError};
use tari_comms::peer_manager::PeerManagerError;
use thiserror::Error;

#[derive(Debug, Error)]
Expand All @@ -47,8 +47,6 @@ pub enum DhtDiscoveryError {
PeerManagerError(#[from] PeerManagerError),
#[error("InvalidPeerMultiaddr: {0}")]
InvalidPeerMultiaddr(String),
#[error("ConnectionManagerError: {0}")]
ConnectionManagerError(#[from] ConnectionManagerError),
}

impl DhtDiscoveryError {
Expand Down
6 changes: 3 additions & 3 deletions comms/dht/tests/dht.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ async fn dht_discover_propagation() {
node_D.comms.peer_manager().add_peer(node_C.to_peer()).await.unwrap();
node_D
.comms
.connection_manager()
.connectivity()
.dial_peer(node_C.comms.node_identity().node_id().clone())
.await
.unwrap();
Expand Down Expand Up @@ -449,7 +449,7 @@ async fn dht_propagate_dedup() {
async fn connect_nodes(node1: &mut TestNode, node2: &mut TestNode) {
node1
.comms
.connection_manager()
.connectivity()
.dial_peer(node2.node_identity().node_id().clone())
.await
.unwrap();
Expand Down Expand Up @@ -553,7 +553,7 @@ async fn dht_propagate_message_contents_not_malleable_ban() {
// Connect the peers that should be connected
node_A
.comms
.connection_manager()
.connectivity()
.dial_peer(node_B.node_identity().node_id().clone())
.await
.unwrap();
Expand Down
7 changes: 1 addition & 6 deletions comms/src/builder/comms_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,12 +337,7 @@ impl CommsNode {
self.hidden_service.as_ref()
}

/// Return an owned copy of a ConnectionManagerRequester. Used to initiate connections to peers.
pub fn connection_manager(&self) -> ConnectionManagerRequester {
self.connection_manager_requester.clone()
}

/// Return an owned copy of a ConnectivityRequester. This is the async interface to the ConnectivityManager
/// Return a handle that is used to call the connectivity service.
pub fn connectivity(&self) -> ConnectivityRequester {
self.connectivity_requester.clone()
}
Expand Down
4 changes: 2 additions & 2 deletions comms/src/builder/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async fn spawn_node(
let (outbound_tx, outbound_rx) = mpsc::channel(10);

let comms_node = CommsBuilder::new()
// These calls are just to get rid of unused function warnings.
// These calls are just to get rid of unused function warnings.
// <IrrelevantCalls>
.with_dial_backoff(ConstantBackoff::new(Duration::from_millis(500)))
.with_shutdown_signal(shutdown_sig)
Expand Down Expand Up @@ -152,7 +152,7 @@ async fn peer_to_peer_custom_protocols() {
.unwrap();

let mut conn_man_events1 = comms_node1.subscribe_connection_manager_events();
let mut conn_man_requester1 = comms_node1.connection_manager();
let mut conn_man_requester1 = comms_node1.connectivity();
let mut conn_man_events2 = comms_node2.subscribe_connection_manager_events();

let mut conn1 = conn_man_requester1
Expand Down
8 changes: 6 additions & 2 deletions comms/src/connectivity/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@ use super::{
selection::ConnectivitySelection,
};
use crate::{
connection_manager::{ConnectionDirection, ConnectionManagerError, ConnectionManagerRequester},
connection_manager::{
ConnectionDirection,
ConnectionManagerError,
ConnectionManagerEvent,
ConnectionManagerRequester,
},
peer_manager::NodeId,
runtime::task,
utils::datetime::format_duration,
ConnectionManagerEvent,
NodeIdentity,
PeerConnection,
PeerManager,
Expand Down
3 changes: 1 addition & 2 deletions comms/src/connectivity/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use super::{
selection::ConnectivitySelection,
};
use crate::{
connection_manager::ConnectionManagerError,
connection_manager::{ConnectionManagerError, ConnectionManagerEvent},
peer_manager::{Peer, PeerFeatures},
runtime,
runtime::task,
Expand All @@ -36,7 +36,6 @@ use crate::{
node_identity::{build_many_node_identities, build_node_identity},
test_node::build_peer_manager,
},
ConnectionManagerEvent,
NodeIdentity,
PeerManager,
};
Expand Down
2 changes: 1 addition & 1 deletion comms/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ mod builder;
pub use builder::{CommsBuilder, CommsBuilderError, CommsNode, UnspawnedCommsNode};

pub mod connection_manager;
pub use connection_manager::{validate_peer_addresses, ConnectionManagerEvent, PeerConnection, PeerConnectionError};
pub use connection_manager::{validate_peer_addresses, PeerConnection, PeerConnectionError};

pub mod connectivity;

Expand Down