예제 #1
0
        /// <inheritdoc />
        public override async Task Handle(VersionMessage message, IPeer sender)
        {
            sender.Version = message.Payload;
            if (_serverContext.Version.Nonce == sender.Version.Nonce)
            {
                throw new InvalidMessageException($"The handshake is failed due to \"{nameof(_serverContext.Version.Nonce)}\" value equality.");
            }

            // Change protocol?
            if (sender.ChangeProtocol(message.Payload))
            {
                _logger?.LogWarning("Changed protocol.");
            }

            // Send Ack
            await sender.Send <VerAckMessage>();
        }