コード例 #1
0
        /// <summary>
        /// is executed by receiver thread
        /// </summary>
        void ProcessRegisterPow1RequestPacket(IPEndPoint requesterEndpoint, byte[] udpData)
        {
            var packet = new RegisterPow1RequestPacket(udpData);

            if (!PassPow1filter(requesterEndpoint, packet))
            {
                if (Configuration.VisionChannel?.GetAttentionTo(Configuration.VisionChannelSourceId, VisionChannelModuleName_reg_epSide) <= AttentionLevel.needsAttention)
                {
                    Configuration.VisionChannel?.Emit(Configuration.VisionChannelSourceId, VisionChannelModuleName_reg_epSide, AttentionLevel.needsAttention, $"pow1 filter rejected request from {requesterEndpoint}");
                }
                return;
            }

            // create Pow2 request state
            var pow2RequestState = _pow2RequestsTable.GenerateOrGetExistingPow2(requesterEndpoint);

            var response = new RegisterPow1ResponsePacket
            {
                ProofOfWork2Request = pow2RequestState.ProofOfWork2Request,
                StatusCode          = RegisterPow1ResponseStatusCode.succeeded_Pow2Challenge,
                Pow1RequestId       = packet.Pow1RequestId
            };

            SendPacket(response.Encode(), requesterEndpoint);
        }
コード例 #2
0
        void RespondToRegisterPow1withError(IPEndPoint requesterEndpoint, RegisterPow1ResponseStatusCode statusCode, uint pow1RequestId)
        {
            var response = new RegisterPow1ResponsePacket
            {
                StatusCode    = statusCode,
                Pow1RequestId = pow1RequestId
            };

            SendPacket(response.Encode(), requesterEndpoint);
        }