public async Task PublishChain(ChainNotify newChain) { foreach (var peer in _peers.GetAll()) { await peer.Address.AppendPathSegments("api", "block", "sync") .PostJsonAsync(newChain.Blocks); } }
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(); } }
// 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(); } }
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); } }
public IEnumerable <Peer> All() { return(_peers.GetAll()); }