MCPcopy Create free account
hub / github.com/dfinity/orbit / validate_unique_hash

Function validate_unique_hash

core/control-panel/impl/src/models/artifact.rs:109–121  ·  view source on GitHub ↗
(self_id: &ArtifactId, hash: &[u8])

Source from the content-addressed store, hash-verified

107}
108
109fn validate_unique_hash(self_id: &ArtifactId, hash: &[u8]) -> ModelValidatorResult<ArtifactError> {
110 ARTIFACT_REPOSITORY
111 .find_by_hash(hash)
112 .map_or(Ok(()), |existing_id| {
113 if existing_id != *self_id {
114 return Err(ArtifactError::ValidationError {
115 info: "Artifact with the same hash already exists".to_string(),
116 });
117 }
118
119 Ok(())
120 })
121}
122
123impl ModelValidator<ArtifactError> for Artifact {
124 fn validate(&self) -> ModelValidatorResult<ArtifactError> {

Callers 1

validateMethod · 0.85

Calls 1

find_by_hashMethod · 0.80

Tested by

no test coverage detected