Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
SWvheerden committed Jan 25, 2024
1 parent 6feca2e commit 17e754b
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 23 deletions.
5 changes: 3 additions & 2 deletions applications/minotari_node/src/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ pub struct BaseNodeBootstrapper<'a, B> {
impl<B> BaseNodeBootstrapper<'_, B>
where B: BlockchainBackend + 'static
{
#[allow(clippy::too_many_lines)]
pub async fn bootstrap(self) -> Result<ServiceHandles, ExitError> {
let mut base_node_config = self.app_config.base_node.clone();
let mut p2p_config = self.app_config.base_node.p2p.clone();
Expand Down Expand Up @@ -174,15 +175,15 @@ where B: BlockchainBackend + 'static

let comms = if p2p_config.transport.transport_type == TransportType::Tor {
let path = base_node_config.tor_identity_file.clone();
let node_id = comms.node_identity().clone();
let node_id = comms.node_identity();
let after_comms = move |identity: TorIdentity| {
let _result = identity_management::save_as_json(&path, &identity);
trace!(target: LOG_TARGET, "resave the tor identity {:?}", identity);
let address: Multiaddr = format!("/onion3/{}:{}", identity.service_id, identity.onion_port)
.parse()
.expect("Should be able to create address");
if !node_id.public_addresses().contains(&address) {
node_id.add_public_address(address.clone());
node_id.add_public_address(address);
}
};
initialization::spawn_comms_using_transport(comms, p2p_config.transport.clone(), after_comms).await
Expand Down
4 changes: 2 additions & 2 deletions base_layer/contacts/src/chat_client/src/networking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ pub async fn start(
}
let comms = if p2p_config.transport.transport_type == TransportType::Tor {
let path = config.chat_client.tor_identity_file.clone();
let node_id = comms.node_identity().clone();
let node_id = comms.node_identity();
let after_comms = move |identity: TorIdentity| {
let _result = identity_management::save_as_json(&path, &identity);
let address: Multiaddr = format!("/onion3/{}:{}", identity.service_id, identity.onion_port)
.parse()
.expect("Should be able to create address");
trace!(target: LOG_TARGET, "resave the chat tor identity {:?}", identity);
if !node_id.public_addresses().contains(&address) {
node_id.add_public_address(address.clone());
node_id.add_public_address(address);
}
};
spawn_comms_using_transport(comms, p2p_config.transport.clone(), after_comms).await?
Expand Down
10 changes: 6 additions & 4 deletions base_layer/core/tests/helpers/nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,10 +451,12 @@ async fn setup_base_node_services(
.await
.unwrap();
// Set the public address for tests
let address = comms.connection_manager_requester().wait_until_listening().await.unwrap();
comms
.node_identity()
.add_public_address(address.bind_address().clone());
let address = comms
.connection_manager_requester()
.wait_until_listening()
.await
.unwrap();
comms.node_identity().add_public_address(address.bind_address().clone());

let outbound_nci = handles.expect_handle::<OutboundNodeCommsInterface>();
let local_nci = handles.expect_handle::<LocalNodeCommsInterface>();
Expand Down
10 changes: 6 additions & 4 deletions base_layer/p2p/tests/support/comms_and_services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ pub async fn setup_comms_services(
.unwrap();

let mut comms = comms.spawn_with_transport(MemoryTransport).await.unwrap();
let address = comms.connection_manager_requester().wait_until_listening().await.unwrap();
let address = comms
.connection_manager_requester()
.wait_until_listening()
.await
.unwrap();
// Set the public address for tests
comms
.node_identity()
.add_public_address(address.bind_address().clone());
comms.node_identity().add_public_address(address.bind_address().clone());

(comms, dht, messaging_events)
}
2 changes: 1 addition & 1 deletion base_layer/wallet/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ where
.expect("P2pInitializer was not added to the stack");
let comms = if config.p2p.transport.transport_type == TransportType::Tor {
let wallet_db = wallet_database.clone();
let node_id = comms.node_identity().clone();
let node_id = comms.node_identity();
let after_comms = move |identity: TorIdentity| {
let address: Multiaddr = format!("/onion3/{}:{}", identity.service_id, identity.onion_port)
.parse()
Expand Down
10 changes: 6 additions & 4 deletions base_layer/wallet/tests/support/comms_and_services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@ pub async fn setup_comms_services(
.unwrap();

let mut comms = comms.spawn_with_transport(MemoryTransport).await.unwrap();
let address = comms.connection_manager_requester().wait_until_listening().await.unwrap();
let address = comms
.connection_manager_requester()
.wait_until_listening()
.await
.unwrap();
// Set the public address for tests
comms
.node_identity()
.add_public_address(address.bind_address().clone());
comms.node_identity().add_public_address(address.bind_address().clone());

(comms, dht)
}
Expand Down
2 changes: 1 addition & 1 deletion comms/core/src/builder/comms_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ impl CommsNode {
self.connection_manager_requester.get_event_subscription()
}

pub fn connection_manager_requester(&mut self)-> &mut ConnectionManagerRequester{
pub fn connection_manager_requester(&mut self) -> &mut ConnectionManagerRequester {
&mut self.connection_manager_requester
}

Expand Down
6 changes: 5 additions & 1 deletion comms/core/src/builder/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ async fn spawn_node(
.spawn_with_transport(MemoryTransport)
.await
.unwrap();
let address = comms_node.connection_manager_requester().wait_until_listening().await.unwrap();
let address = comms_node
.connection_manager_requester()
.wait_until_listening()
.await
.unwrap();
unpack_enum!(Protocol::Memory(_port) = address.bind_address().iter().next().unwrap());

(comms_node, inbound_rx, outbound_tx, messaging_events_sender)
Expand Down
6 changes: 5 additions & 1 deletion comms/core/tests/tests/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ async fn spawn_node(signal: ShutdownSignal) -> (CommsNode, RpcServerHandle) {
.await
.unwrap();

let address = comms.connection_manager_requester().wait_until_listening().await.unwrap();
let address = comms
.connection_manager_requester()
.wait_until_listening()
.await
.unwrap();
comms
.node_identity()
.set_public_addresses(vec![address.bind_address().clone()]);
Expand Down
6 changes: 5 additions & 1 deletion comms/core/tests/tests/rpc_stress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ async fn spawn_node(signal: ShutdownSignal) -> CommsNode {
.await
.unwrap();

let address = comms.connection_manager_requester().wait_until_listening().await.unwrap();
let address = comms
.connection_manager_requester()
.wait_until_listening()
.await
.unwrap();
comms
.node_identity()
.set_public_addresses(vec![address.bind_address().clone()]);
Expand Down
7 changes: 5 additions & 2 deletions comms/core/tests/tests/substream_stress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ pub async fn spawn_node(signal: ShutdownSignal) -> (CommsNode, ProtocolNotificat
.await
.unwrap();


let address = comms.connection_manager_requester().wait_until_listening().await.unwrap();
let address = comms
.connection_manager_requester()
.wait_until_listening()
.await
.unwrap();
comms
.node_identity()
.set_public_addresses(vec![address.bind_address().clone()]);
Expand Down

0 comments on commit 17e754b

Please sign in to comment.