private void OnPerpareResponseReceived(ConsensusPayload payload, PerpareResponse message)
        {
            Log($"{nameof(OnPerpareResponseReceived)}: height={payload.Height} view={message.ViewNumber} index={payload.MinerIndex}");
            if (context.State.HasFlag(ConsensusState.BlockSent))
            {
                return;
            }
            if (context.Signatures[payload.MinerIndex] != null)
            {
                return;
            }
            Block header = context.MakeHeader();

            if (header == null || !header.VerifySignature(context.Miners[payload.MinerIndex], message.Signature))
            {
                return;
            }
            context.Signatures[payload.MinerIndex] = message.Signature;
            CheckSignatures();
        }
示例#2
0
        private void OnPerpareResponseReceived(ConsensusPayload payload, PerpareResponse message)
        {
            Log($"{nameof(OnPerpareResponseReceived)}: height={payload.BlockIndex} view={message.ViewNumber} index={payload.ValidatorIndex}");
            if (context.State.HasFlag(ConsensusState.BlockSent))
            {
                return;
            }
            if (context.Signatures[payload.ValidatorIndex] != null)
            {
                return;
            }
            Block header = context.MakeHeader();

            if (header == null || !Crypto.Default.VerifySignature(header.GetHashData(), message.Signature, context.Validators[payload.ValidatorIndex].EncodePoint(false)))
            {
                return;
            }
            context.Signatures[payload.ValidatorIndex] = message.Signature;
            CheckSignatures();
        }