Skip to content

Commit

Permalink
formatting and remove unnecesary let
Browse files Browse the repository at this point in the history
  • Loading branch information
czarte committed Nov 1, 2024
1 parent 2474e75 commit 6f4c6d1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
32 changes: 25 additions & 7 deletions node/src/neighborhood/gossip_acceptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,13 @@ impl GossipHandler for DebutHandler {
source_node_addr,
);
}
if let Ok(result) = self.try_accept_debut(cryptde, database, &source_agr, gossip_source, neighborhood_metadata.exit_tools_opt) {
if let Ok(result) = self.try_accept_debut(
cryptde,
database,
&source_agr,
gossip_source,
neighborhood_metadata.exit_tools_opt,
) {
return result;
}
debug!(self.logger, "Seeking neighbor for Pass");
Expand Down Expand Up @@ -276,7 +282,7 @@ impl DebutHandler {
let mut debuting_node = NodeRecord::from(debuting_agr);
match exit_tools_opt {
Some(exit_tools) => exit_tools.assign_nodes_country_undesirability(&mut debuting_node),
None => ()
None => (),
}

// TODO 468 make debuting_node mut and add country_undesirability to its metadata
Expand Down Expand Up @@ -693,7 +699,12 @@ impl GossipHandler for IntroductionHandler {
.expect("IP Address not found for the Node Addr.")
.ip_addr();
// TODO 468 pass the NeighborhoodMetadata into update_database
match self.update_database(database, cryptde, introducer, neighborhood_metadata.exit_tools_opt) {
match self.update_database(
database,
cryptde,
introducer,
neighborhood_metadata.exit_tools_opt,
) {
Ok(_) => (),
Err(e) => {
return GossipAcceptanceResult::Ban(format!(
Expand Down Expand Up @@ -853,7 +864,7 @@ impl IntroductionHandler {
database: &mut NeighborhoodDatabase,
cryptde: &dyn CryptDE,
introducer: AccessibleGossipRecord,
exit_tools_opt: Option<ExitTools>
exit_tools_opt: Option<ExitTools>,
) -> Result<bool, String> {
let introducer_key = introducer.inner.public_key.clone();
match database.node_by_key_mut(&introducer_key) {
Expand Down Expand Up @@ -881,7 +892,9 @@ impl IntroductionHandler {
let mut new_introducer = NodeRecord::from(introducer);
//TODO 468 add country undesirability
match exit_tools_opt {
Some(exit_tools) => exit_tools.assign_nodes_country_undesirability(&mut new_introducer),
Some(exit_tools) => {
exit_tools.assign_nodes_country_undesirability(&mut new_introducer)
}
None => (),
}
//TODO probably make one function to use on all places
Expand Down Expand Up @@ -1394,7 +1407,9 @@ mod tests {
use crate::neighborhood::gossip_producer::GossipProducer;
use crate::neighborhood::gossip_producer::GossipProducerReal;
use crate::neighborhood::node_record::NodeRecord;
use crate::neighborhood::{COUNTRY_UNDESIRABILITY_FACTOR, ExitPreference, ExitTools, UNREACHABLE_COUNTRY_PENALTY};
use crate::neighborhood::{
ExitPreference, ExitTools, COUNTRY_UNDESIRABILITY_FACTOR, UNREACHABLE_COUNTRY_PENALTY,
};
use crate::sub_lib::cryptde_null::CryptDENull;
use crate::sub_lib::neighborhood::{
ConnectionProgressEvent, ConnectionProgressMessage, ExitLocation,
Expand Down Expand Up @@ -3108,7 +3123,10 @@ Length: 24 (0x18) bytes
let reference_node = dest_db.node_by_key_mut(debut_node.public_key()).unwrap();
debut_node.metadata.last_update = reference_node.metadata.last_update;
debut_node.resign();
assert_eq!(reference_node.metadata.country_undesirability, UNREACHABLE_COUNTRY_PENALTY);
assert_eq!(
reference_node.metadata.country_undesirability,
UNREACHABLE_COUNTRY_PENALTY
);
reference_node.metadata.country_undesirability = 0u32;
assert_node_records_eq(reference_node, &debut_node, before, after);
}
Expand Down
5 changes: 2 additions & 3 deletions node/src/neighborhood/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1587,7 +1587,7 @@ impl Neighborhood {
&mut self,
message: &UiSetExitLocationRequest,
) -> Vec<ExitLocation> {
let exit_location_vec = message
message
.to_owned()
.exit_locations
.into_iter()
Expand All @@ -1600,8 +1600,7 @@ impl Neighborhood {
priority: cc.priority,
}
})
.collect();
exit_location_vec
.collect()
}

fn handle_gossip_reply(
Expand Down

0 comments on commit 6f4c6d1

Please sign in to comment.