/// <summary>
        /// Occurs when the peers change - We need to check what our peer has for the blockchain
        /// </summary>
        /// <param name="sender">Sender of the event</param>
        /// <param name="e">Peer change arguments</param>
        private async void TransportManagerOnPeerChange(object sender, PeerChangeEventArgs e)
        {
            // TODO - We need to get the latest block from each peer, if the blocks do not match we need to get the latest chain
            foreach (var peer in e.Peers)
            {
                await _directRequestSemaphore.WaitAsync();

                var container = new MessageContainer
                {
                    MessageType = MessageType.RequestLastBlock
                };
                await peer.SendMsgTCPAsync(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(container)));
            }
        }
Exemplo n.º 2
0
        private void NewPeer_peerStatusChange(object sender, PeerEventArgs e)
        {
            Peer changedPeer = e.Peer;

            //delete inactive peers
            bool isPeerActive = changedPeer.IsPeerActive;

            if (!isPeerActive)
            {
                //delete from list
                knownPeers.Remove(changedPeer);
            }
            var pcea = new PeerChangeEventArgs(knownPeers);

            if (!isPeerActive)
            {
                pcea.removedPeer = changedPeer;
            }
            //tell others a peer has been deleted
            PeerChange?.Invoke(this, pcea);
        }
Exemplo n.º 3
0
 private void BaseStation_PeerChange(object sender, PeerChangeEventArgs e)
 {
     PeerChange?.Invoke(this, e);
 }
Exemplo n.º 4
0
 private void ObjManager_PeerChange(object sender, PeerChangeEventArgs e)
 {
     this.PeerChange?.Invoke(this, e);
 }
Exemplo n.º 5
0
        /// <summary>
        /// Raises the PeerDisconnected event.
        /// </summary>
        /// <param name="e">Desired event arguments.</param>
        protected virtual void OnPeerDisconnected(PeerChangeEventArgs e)
        {
            ClientEventHandler<PeerChangeEventArgs> handler = PeerDisconnected;

            if (handler != null)
            {
                handler(this, e);
            }
        }