Update function definition for bridge update

This commit is contained in:
onyinyang 2023-03-23 11:00:10 -04:00
parent 80dd16f081
commit 6681289105
No known key found for this signature in database
GPG Key ID: 156A6435430C2036
1 changed files with 25 additions and 3 deletions

View File

@ -309,9 +309,31 @@ impl BridgeAuth {
self.bridge_table.spares.insert(bnum);
}
pub fn bridge_update(&mut self, bridge: &BridgeLine, bdb: &mut BridgeDb) -> bool {
// 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 {
false
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