Example #1
0
        private IEnumerable <BroadcastProfileMessage> GetProfiles(IEnumerable <Signature> trustSignatures)
        {
            var profiles = new List <BroadcastProfileMessage>();

            foreach (var trustSignature in trustSignatures)
            {
                var profile = _amoebaInterfaceManager.GetProfile(trustSignature, CancellationToken.None).Result;

                if (profile == null)
                {
                    if (_cacheProfiles.TryGetValue(trustSignature, out var cachedProfile))
                    {
                        profiles.Add(cachedProfile);
                    }
                }
                else
                {
                    if (!_cacheProfiles.TryGetValue(trustSignature, out var cachedProfile) ||
                        profile.CreationTime > cachedProfile.CreationTime)
                    {
                        _cacheProfiles[trustSignature] = profile;
                        profiles.Add(profile);
                    }
                    else
                    {
                        profiles.Add(cachedProfile);
                    }
                }
            }

            return(profiles);
        }