public async void OnNext(IPeerReputationChange peerReputationChange)
        {
            await SemaphoreSlim.WaitAsync().ConfigureAwait(false);

            try
            {
                var peer = PeerRepository.GetAll().FirstOrDefault(p => p.PeerId.Equals(peerReputationChange.PeerId));
                Guard.Argument(peer, nameof(peer)).NotNull();

                peer.Reputation += peerReputationChange.ReputationEvent.Amount;
                PeerRepository.Update(peer);
            }
            finally
            {
                SemaphoreSlim.Release();
            }
        }
Esempio n. 2
0
        // ReSharper disable once VSTHRD100
        public async void OnNext(IPeerReputationChange peerReputationChange)
        {
            try
            {
                await SemaphoreSlim.WaitAsync().ConfigureAwait(false);

                var peer = PeerRepository.GetAll().FirstOrDefault(p => p.PeerId.Equals(peerReputationChange.PeerId));
                Guard.Argument(peer, nameof(peer)).NotNull();

                // ReSharper disable once PossibleNullReferenceException
                peer.Reputation += peerReputationChange.ReputationEvent.Amount;
                PeerRepository.Update(peer);
            }
            catch (Exception e)
            {
                _logger.Error(e, e.Message);
            }
            finally
            {
                SemaphoreSlim.Release();
            }
        }
Esempio n. 3
0
        public void OnNext(IPeerReputationChange peerReputationChange)
        {
            try
            {
                var peer = PeerRepository.GetAll().FirstOrDefault(p => p.PeerId.Equals(peerReputationChange.PeerId));
                //todo come back to later
                if (peer == null)
                {
                    return;
                }

                Guard.Argument(peer, nameof(peer)).NotNull();

                // ReSharper disable once PossibleNullReferenceException
                peer.Reputation += peerReputationChange.ReputationEvent.Amount;
                PeerRepository.Update(peer);
            }
            catch (Exception e)
            {
                _logger.Error(e, e.Message);
            }
        }