| 194 | |
| 195 | impl OperationPayload { |
| 196 | fn canonicalize(&mut self) -> Result<(), OperationCodecError> { |
| 197 | self.parents.sort_unstable(); |
| 198 | self.parents.dedup(); |
| 199 | self.evidence.sort_unstable(); |
| 200 | self.evidence.dedup(); |
| 201 | self.git_observed |
| 202 | .sort_by(|left, right| left.name.cmp(&right.name)); |
| 203 | reject_duplicate_git_ref_names(&self.git_observed)?; |
| 204 | for note in &mut self.lossy { |
| 205 | note.evidence.sort_unstable(); |
| 206 | note.evidence.dedup(); |
| 207 | } |
| 208 | self.lossy.sort_unstable(); |
| 209 | self.lossy.dedup(); |
| 210 | self.delta.canonicalize()?; |
| 211 | self.validate_canonical() |
| 212 | } |
| 213 | |
| 214 | pub(crate) fn validate_canonical(&self) -> Result<(), OperationCodecError> { |
| 215 | ensure_strictly_sorted(&self.parents, "operation parents")?; |