Fix up bridge_unreachable

This commit is contained in:
onyinyang 2023-06-20 17:49:41 -04:00
parent 0ede04164b
commit 610a579731
No known key found for this signature in database
GPG Key ID: 156A6435430C2036
2 changed files with 7 additions and 6 deletions

View File

@ -368,7 +368,7 @@ impl BridgeAuth {
if let Some(v) = positions {
for (bucketnum, offset) in v.iter() {
println!("Bucket num: {:?} and offset: {:?}", bucketnum, offset);
let bridgelines = match self.bridge_table.buckets.get(bucketnum) {
let mut bridgelines = match self.bridge_table.buckets.get(bucketnum) {
Some(bridgelines) => *bridgelines,
None => return res,
};
@ -526,14 +526,15 @@ impl BridgeAuth {
if let Some(v) = positions {
for (bucketnum, offset) in v.iter() {
// Count how many bridges in this bucket are reachable
let numreachable = self.bridge_table.buckets[*bucketnum as usize]
let mut bucket = self.bridge_table.buckets.get(bucketnum).unwrap();
let numreachable = bucket
.iter()
.filter(|br| self.bridge_table.reachable.get(br).is_some())
.count();
// Remove the bridge from the bucket
assert!(self.bridge_table.buckets[*bucketnum as usize][*offset] == *bridge);
self.bridge_table.buckets[*bucketnum as usize][*offset] = BridgeLine::default();
assert!(bucket[*offset] == *bridge);
bucket[*offset] = BridgeLine::default();
// Is this bucket an open-invitation bucket?
if bdb.openinv_buckets.contains(bucketnum) {

View File

@ -159,8 +159,8 @@ pub fn encrypt_cred_ids(
migrationkey_priv: &IssuerPrivKey,
) -> Option<([u8; 16], [u8; ENC_MIGRATION_BYTES])> {
// Look up the bucket keys and form the attributes (Scalars)
let fromkey = bridgetable.keys.get(from_id as usize)?;
let tokey = bridgetable.keys.get(to_id as usize)?;
let fromkey = bridgetable.keys.get(&from_id)?;
let tokey = bridgetable.keys.get(&to_id)?;
Some(encrypt_cred(
id,
&bridge_table::to_scalar(from_id, fromkey),