namespace WxAgent.Core;
public sealed record AccountDatabaseEntry(string Fingerprint, string RelativePath);
/// Decides which verified keys may be reused from cache, avoiding repeated memory scans for cached accounts.
public static class KeyCachePlanner
{
public static string Key(string accountFingerprint, string relativePath) =>
$"{accountFingerprint}|{relativePath}";
public static IReadOnlySet VerifiedKeys(IEnumerable cached)
{
var set = new HashSet(StringComparer.OrdinalIgnoreCase);
foreach (var account in cached)
foreach (var database in account.Databases)
set.Add(Key(account.AccountRootFingerprint, database.RelativePath));
return set;
}
public static bool HasPending(IEnumerable discovered, IReadOnlySet verified)
{
foreach (var entry in discovered)
{
if (!verified.Contains(Key(entry.Fingerprint, entry.RelativePath)))
{
return true;
}
}
return false;
}
}