Skip to content

Commit

Permalink
dcatomic: Add DC Parameter elements to the file hash
Browse files Browse the repository at this point in the history
  • Loading branch information
maxrdz committed Feb 25, 2024
1 parent a94f7d6 commit 68b8e6f
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions libdonet/src/dcatomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
use crate::dcfield::{DCField, DCFieldInterface};
use crate::dclass::DClass;
use crate::dcparameter::DCParameter;
use crate::dcparameter::{DCParameter, DCParameterInterface};
use crate::dctype::{DCTypeDefinition, DCTypeDefinitionInterface};
use crate::hashgen::DCHashGenerator;
use std::sync::{Arc, Mutex};
use std::ops::Deref;
use std::sync::{Arc, Mutex, MutexGuard};

/// Represents an atomic field of a Distributed Class.
/// This defines the interface to a DClass object, and is
Expand Down Expand Up @@ -57,9 +58,19 @@ impl DCAtomicFieldInterface for DCAtomicField {
}
}

/// Accumulates the properties of this DC element into the file hash.
fn generate_hash(&self, hashgen: &mut DCHashGenerator) {
self.base_field.generate_hash(hashgen);
// TODO!

hashgen.add_int(self.elements.len().try_into().unwrap());

for param_ptr in &self.elements {
let new_ptr: Arc<Mutex<DCParameter>> = param_ptr.clone();
let mutex_ref: &Mutex<DCParameter> = new_ptr.deref();
let param: MutexGuard<'_, DCParameter> = mutex_ref.lock().unwrap();

param.generate_hash(hashgen);
}
}

fn get_num_elements(&self) -> usize {
Expand Down

0 comments on commit 68b8e6f

Please sign in to comment.