Example #1
0
        /// <summary>
        /// Sets all the fields and gets lists of all alive- and dead peers
        /// Then sets the state of the suspected peers to MaybeDead on the vote
        /// </summary>
        /// <param name="networkListener">The NetworkListener to register new PingRequestResponseListeners in if this should time out</param>
        /// <param name="vote">The current vote that are being processed</param>
        /// <param name="retries">Counter for recursion level as PRRLs can create new PRRLs</param>
        private PingRequestResponseListener(NetworkListener networkListener, Vote vote, int retries)
        {
            this.networkListener = networkListener;
            this.vote            = vote;
            this.retries         = retries;

            var alivePeers = (from peer in vote.VoteReplyList where peer.Value select peer.Key).ToList();
            var deadPeers  = (from peer in vote.VoteReplyList where !peer.Value select peer.Key).ToList();

            foreach (var deadPeer in deadPeers)
            {
                vote.SetPeerState(deadPeer, PeerState.MaybeDead);
                var dict = alivePeers.ToDictionary(peer => peer, peer => PingRequestResponse.NotYet);
                nonRespondingPeers.Add(deadPeer, dict);
            }
        }
Example #2
0
 /// <summary>
 /// Create a new PingRequestResponseListener that will listen for responses to Ping requests
 /// </summary>
 /// <param name="networkListener">The current networklistener</param>
 /// <param name="vote">The vote being worked on</param>
 public PingRequestResponseListener(NetworkListener networkListener, Vote vote) : this(networkListener, vote, 0)
 {
     //This constructor gives public access to this class without exposing the recursion counter
 }
Example #3
0
 /// <summary>
 /// Create a new PingRequest listener to listen for PingRequests
 /// </summary>
 /// <param name="networkListener">The NetworkListener to register the created PongListeners in</param>
 public PingRequestListener(NetworkListener networkListener)
 {
     this.networkListener = networkListener;
 }
Example #4
0
 /// <summary>
 /// Initialises the VoteResponseListener and stores the provided NetworkListener
 /// and Vote to the instance fields.
 /// </summary>
 /// <param name="networkListener">The NetworkListener that VoteResponseListener needs</param>
 /// <param name="vote">The Vote that VoteResponseListener needs</param>
 public VoteReponseListener(NetworkListener networkListener, Vote vote)
 {
     this.networkListener = networkListener;
     this.vote            = vote;
 }