diff --git a/crates/lox-library/src/lib.rs b/crates/lox-library/src/lib.rs index ff23039..ec352b2 100644 --- a/crates/lox-library/src/lib.rs +++ b/crates/lox-library/src/lib.rs @@ -309,9 +309,31 @@ impl BridgeAuth { self.bridge_table.spares.insert(bnum); } - pub fn bridge_update(&mut self, bridge: &BridgeLine, bdb: &mut BridgeDb) -> bool { - - false + // Update the details of a bridge in the bridge table. This assumes that the IP and Port + // of a given bridge remains the same and thus can be updated. + // First we must retrieve the list of reachable bridges, then we must search for any matching our partial key + // which will include the IP and Port. Then we can replace the original bridge with the updated bridge or else + // or else just replace the info field. + pub fn bridge_update(&mut self, bridge: &BridgeLine) -> bool { + + let mut res: bool = false; //default False to assume that update failed + //Needs to be updated since bridge will only match on some fields. + let positions = self.bridge_table.reachable.get_key_value(bridge); + if let Some(v) = positions { + println!("Bridge v: {:?} has same IP and Port as bridge {:?}.", v.0, bridge); + let mut w = *v.0; + w.info = bridge.info; + if v.0 == bridge { + println!("Yay"); + println!("Now bridge v: {:?} has all fields the same as bridge {:?}.", v.0, bridge); + }else { + println!("Boo"); + } + res = true; + + } + + res } /// Mark a bridge as unreachable