Skip to content

Commit

Permalink
Minor fix on types used for VersionVector
Browse files Browse the repository at this point in the history
  • Loading branch information
rcmgleite committed Jul 12, 2024
1 parent b12cd90 commit 074fdc5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/persistency/versioning/version_vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ impl VersionVector {
where
F: FnMut(&ProcessId, &Version, &Version),
{
let mut process_ids: Vec<&u128> = lhs.versions.keys().chain(rhs.versions.keys()).collect();
let mut process_ids: Vec<&ProcessId> =
lhs.versions.keys().chain(rhs.versions.keys()).collect();
process_ids.sort();
process_ids.dedup();
let process_ids = process_ids.into_iter();
Expand Down Expand Up @@ -148,7 +149,7 @@ impl VersionVector {

/// returns the expected serialized size of the given [`VersionVector`] instance
pub fn serialized_size(&self) -> usize {
size_of::<u32>() + self.versions.len() * 2 * size_of::<u128>()
size_of::<u32>() + self.versions.len() * 2 * size_of::<ProcessId>()
}

/// Deserializes [bytes::Bytes] into [`VersionVector`]
Expand All @@ -160,7 +161,7 @@ impl VersionVector {
}

let n_items = serialized_vv.get_u32() as usize;
let expected_size = n_items * 2 * size_of::<u128>();
let expected_size = n_items * 2 * size_of::<ProcessId>();
if serialized_vv.len() != expected_size {
return Err(Error::Internal(crate::error::Internal::Unknown { reason: format!(
"buffer provided to deserialize into VersionVector has the wrong size. Expected {}, got {}", expected_size, serialized_vv.len())}));
Expand Down Expand Up @@ -330,7 +331,7 @@ mod tests {
let serialized = vv.serialize();
assert_eq!(
serialized.len(),
size_of::<u32>() + (vv.versions.len() * 2 * size_of::<u128>())
size_of::<u32>() + (vv.versions.len() * 2 * size_of::<ProcessId>())
);

let deserialized = VersionVector::deserialize(vv.id, serialized).unwrap();
Expand Down

0 comments on commit 074fdc5

Please sign in to comment.