添加或更新

This commit is contained in:
陈国伟 2021-06-16 14:33:59 +08:00
parent 849d622bc6
commit f89952dd18
2 changed files with 11 additions and 3 deletions

View File

@ -10,11 +10,19 @@ namespace FastGithub.Scanner
private readonly HashSet<GithubContext> contextHashSet = new();
private readonly Dictionary<string, IPAddress> domainAdressCache = new();
public bool Add(GithubContext context)
public void AddOrUpdate(GithubContext context)
{
lock (this.syncRoot)
{
return this.contextHashSet.Add(context);
if (this.contextHashSet.TryGetValue(context, out var value))
{
value.Elapsed = context.Elapsed;
value.Available = context.Available;
}
else
{
this.contextHashSet.Add(context);
}
}
}

View File

@ -62,7 +62,7 @@ namespace FastGithub.Scanner
await this.fullScanDelegate(context);
if (context.Available == true)
{
this.results.Add(context);
this.results.AddOrUpdate(context);
}
}
}