MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / refresh

Function refresh

libatomic/src/signer_refresh.rs:26–50  ·  view source on GitHub ↗

Discover only unresolved DIDs, with no pristine transaction held over I/O. Older storage versions cannot resolve fingerprint DIDs: that is a cache miss, never permission to interpret the fingerprint bytes as a public key.

(repo: &Repository, client: &StorageClient)

Source from the content-addressed store, hash-verified

24/// Older storage versions cannot resolve fingerprint DIDs: that is a cache
25/// miss, never permission to interpret the fingerprint bytes as a public key.
26pub async fn refresh(repo: &Repository, client: &StorageClient) -> Result<usize, RepositoryError> {
27 let signers = repo.unresolved_attestation_signers()?;
28 let mut cached = 0;
29 for did in signers {
30 let response = tokio::time::timeout(
31 std::time::Duration::from_secs(10),
32 client.resolve_identity_by_public_key(&did),
33 )
34 .await;
35 let Some(key) = response
36 .ok()
37 .and_then(Result::ok)
38 .and_then(|identity| identity.public_key)
39 .and_then(|key| PublicKey::from_base32(&key).ok())
40 else {
41 continue;
42 };
43 if !atomic_canonical::did::did_matches_public_key(&did, &key) {
44 continue;
45 }
46 repo.cache_signer_key(&did, &key)?;
47 cached += 1;
48 }
49 Ok(cached)
50}

Callers 2

pull_changes_implFunction · 0.85

Calls 5

did_matches_public_keyFunction · 0.85
cache_signer_keyMethod · 0.80
okMethod · 0.45

Tested by

no test coverage detected