MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / update_provider

Method update_provider

nodedb/src/control/security/jwks/cache.rs:58–77  ·  view source on GitHub ↗

Update all keys for a provider (atomic swap).

(&self, provider: &str, keys: Vec<VerificationKey>)

Source from the content-addressed store, hash-verified

56
57 /// Update all keys for a provider (atomic swap).
58 pub fn update_provider(&self, provider: &str, keys: Vec<VerificationKey>) {
59 let now = Instant::now();
60 let key_map: HashMap<String, VerificationKey> =
61 keys.into_iter().map(|k| (k.kid.clone(), k)).collect();
62
63 let mut providers = self.providers.write().unwrap_or_else(|p| p.into_inner());
64 providers.insert(
65 provider.to_string(),
66 ProviderKeys {
67 keys: key_map,
68 fetched_at: now,
69 last_refetch_attempt: now,
70 },
71 );
72
73 // Persist to disk if configured.
74 if let Some(ref path) = self.disk_path {
75 let _ = self.persist_to_disk(path, &providers);
76 }
77 }
78
79 /// Check if enough time has passed since last re-fetch attempt.
80 /// Used to rate-limit on-demand re-fetches for unknown `kid`.

Callers 4

cache_get_and_updateFunction · 0.80
refetch_rate_limitingFunction · 0.80
staleness_checkFunction · 0.80
fetch_and_cacheFunction · 0.80

Calls 7

nowFunction · 0.85
collectMethod · 0.80
to_stringMethod · 0.80
persist_to_diskMethod · 0.80
cloneMethod · 0.45
writeMethod · 0.45
insertMethod · 0.45

Tested by 3

cache_get_and_updateFunction · 0.64
refetch_rate_limitingFunction · 0.64
staleness_checkFunction · 0.64