Exemplo n.º 1
0
        private void Refresh()
        {
            var trustSignatures = new HashSet <string>();

            {
                var linkItems = new HashSet <LinkItem>();

                foreach (var leaderSignature in Settings.Instance.Global_TrustSignatures.ToArray())
                {
                    var targetLinkItems = new List <LinkItem>();

                    var targetSignatures  = new HashSet <string>();
                    var checkedSignatures = new HashSet <string>();

                    targetSignatures.Add(leaderSignature);

                    for (int i = 0; i < 32; i++)
                    {
                        var tempLinkItems = this.GetLinkItems(targetSignatures).ToList();
                        if (tempLinkItems.Count == 0)
                        {
                            break;
                        }

                        checkedSignatures.UnionWith(targetSignatures);
                        checkedSignatures.UnionWith(tempLinkItems.SelectMany(n => n.DeleteSignatures));

                        targetSignatures.Clear();
                        targetSignatures.UnionWith(tempLinkItems.SelectMany(n => n.TrustSignatures).Where(n => !checkedSignatures.Contains(n)));

                        targetLinkItems.AddRange(tempLinkItems);

                        if (targetLinkItems.Count > 1024 * 32)
                        {
                            goto End;
                        }
                    }

                    End :;

                    linkItems.UnionWith(targetLinkItems.Take(1024 * 32));
                }

                lock (_cache_LinkItems.ThisLock)
                {
                    _cache_LinkItems.Clear();

                    foreach (var linkItem in linkItems)
                    {
                        _cache_LinkItems.Add(linkItem.Signature, linkItem);
                    }
                }

                trustSignatures.UnionWith(linkItems.Select(n => n.Signature).ToArray());
            }

            {
                Inspect.SetTrustSignatures(trustSignatures);
                _amoebaManager.SetTrustSignatures(trustSignatures);

                foreach (var signature in Settings.Instance.Cache_Links.Keys.ToArray())
                {
                    if (!trustSignatures.Contains(signature))
                    {
                        Settings.Instance.Cache_Links.Remove(signature);
                    }
                }

                foreach (var signature in Settings.Instance.Cache_Profiles.Keys.ToArray())
                {
                    if (!trustSignatures.Contains(signature))
                    {
                        Settings.Instance.Cache_Profiles.Remove(signature);
                    }
                }

                foreach (var signature in Settings.Instance.Cache_Stores.Keys.ToArray())
                {
                    if (!trustSignatures.Contains(signature))
                    {
                        Settings.Instance.Cache_Stores.Remove(signature);
                    }
                }
            }
        }