MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / load_measurements_from_cache

Method load_measurements_from_cache

verifier/src/verification.rs:176–209  ·  view source on GitHub ↗
(&self, cache_key: &str)

Source from the content-addressed store, hash-verified

174 }
175
176 fn load_measurements_from_cache(&self, cache_key: &str) -> Result<Option<TdxMeasurements>> {
177 let path = self.measurement_cache_path(cache_key);
178 if !path.exists() {
179 return Ok(None);
180 }
181
182 let path_display = path.display().to_string();
183 let contents = match fs_err::read(&path) {
184 Ok(data) => data,
185 Err(e) => {
186 warn!("Failed to read measurement cache {}: {e:?}", path_display);
187 return Ok(None);
188 }
189 };
190
191 let cached: CachedMeasurement = match serde_json::from_slice(&contents) {
192 Ok(entry) => entry,
193 Err(e) => {
194 warn!("Failed to parse measurement cache {}: {e:?}", path_display);
195 return Ok(None);
196 }
197 };
198
199 if cached.version != MEASUREMENT_CACHE_VERSION {
200 debug!(
201 "Ignoring measurement cache {} due to version mismatch (found {}, expected {})",
202 path_display, cached.version, MEASUREMENT_CACHE_VERSION
203 );
204 return Ok(None);
205 }
206
207 debug!("Loaded measurement cache entry {}", cache_key);
208 Ok(Some(cached.measurements))
209 }
210
211 fn store_measurements_in_cache(
212 &self,

Callers 1

Calls 2

displayMethod · 0.80

Tested by

no test coverage detected