Exemplo n.º 1
0
        public async Task Handle(VersionMessage message, IPeer sender)
        {
            if (_server.Nonce != message.Payload.Nonce)
            {
                throw new InvalidOperationException("The handshake failed.");
            }

            if (_server.Version > message.Payload.Version)
            {
                _logger.LogWarning("Downgraded to lower protocol version.");
                sender.DowngradeProtocol(message.Payload.Version);
            }

            await sender.Send <VerAckMessage>();
        }
Exemplo n.º 2
0
        public async Task Handle(VersionMessage message, IPeer sender)
        {
            sender.Version = message.Payload;

            if (_server.Nonce == sender.Version.Nonce)
            {
                throw new InvalidOperationException($"The handshake is failed due to \"{nameof(_server.Nonce)}\" value equality.");
            }

            if (_server.ProtocolVersion > sender.Version.Version)
            {
                _logger.LogWarning("Downgraded to a lower protocol version.");
                sender.DowngradeProtocol(sender.Version.Version);
            }

            await sender.Send <VerAckMessage>();
        }