refactor: split node agent and Go control plane
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
namespace WxAgent.Core;
|
||||
|
||||
public sealed record AccountDatabaseEntry(string Fingerprint, string RelativePath);
|
||||
|
||||
/// <summary>Decides which verified keys may be reused from cache, avoiding repeated memory scans for cached accounts.</summary>
|
||||
public static class KeyCachePlanner
|
||||
{
|
||||
public static string Key(string accountFingerprint, string relativePath) =>
|
||||
$"{accountFingerprint}|{relativePath}";
|
||||
|
||||
public static IReadOnlySet<string> VerifiedKeys(IEnumerable<AccountKeySet> cached)
|
||||
{
|
||||
var set = new HashSet<string>(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<AccountDatabaseEntry> discovered, IReadOnlySet<string> verified)
|
||||
{
|
||||
foreach (var entry in discovered)
|
||||
{
|
||||
if (!verified.Contains(Key(entry.Fingerprint, entry.RelativePath)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user