Beispiel #1
0
 public void SetConfig(MessageConfig config)
 {
     lock (_lockObject)
     {
         _searchSignatures.Clear();
         _searchSignatures.UnionWith(config.SearchSignatures);
     }
 }
Beispiel #2
0
 public static void SetTrustSignatures(IEnumerable <string> signatures)
 {
     lock (_trustSignatures.ThisLock)
     {
         _trustSignatures.Clear();
         _trustSignatures.UnionWith(signatures);
     }
 }
Beispiel #3
0
        private void UpdateProfiles()
        {
            var searchSignatures = new HashSet <Signature>();

            {
                var profiles = new HashSet <BroadcastMessage <Profile> >();

                foreach (var leaderSignature in SettingsManager.Instance.SubscribeSignatures.ToArray())
                {
                    var targetProfiles = new List <BroadcastMessage <Profile> >();

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

                    targetSignatures.Add(leaderSignature);

                    for (int i = 0; i < 32; i++)
                    {
                        searchSignatures.UnionWith(targetSignatures);

                        var tempProfiles = this.GetProfiles(targetSignatures).ToList();
                        if (tempProfiles.Count == 0)
                        {
                            break;
                        }

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

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

                        targetProfiles.AddRange(tempProfiles);

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

                    End :;

                    profiles.UnionWith(targetProfiles.Take(1024 * 32));
                }

                lock (_cacheProfiles.LockObject)
                {
                    _cacheProfiles.Clear();

                    foreach (var profile in profiles)
                    {
                        _cacheProfiles.Add(profile.AuthorSignature, profile);
                    }
                }
            }

            lock (_trustSignatures.LockObject)
            {
                _trustSignatures.Clear();
                _trustSignatures.UnionWith(searchSignatures);
            }

            searchSignatures.Add(SettingsManager.Instance.AccountInfo.DigitalSignature.GetSignature());

            lock (_serviceManager.LockObject)
            {
                var oldConfig = _serviceManager.Config;
                _serviceManager.SetConfig(new ServiceConfig(oldConfig.Core, oldConfig.Connection, new MessageConfig(searchSignatures)));
            }
        }