예제 #1
0
        public bool AddAuthResult(AuthorizedMsg msg)
        {
            // check repeated message
            if (OutputMsgs.ToList().Any(a => a.From == msg.From))
            {
                return(false);
            }

            // only when success there is AuthSign
            if (msg.Result == APIResultCodes.Success && msg.AuthSign != null)
            {
                if (msg.From != msg.AuthSign.Key)
                {
                    return(false);
                }

                // verify signature
                if (!Signatures.VerifyAccountSignature(InputMsg.Block.Hash, msg.AuthSign.Key, msg.AuthSign.Signature))
                {
                    _log.LogError($"AuthorizedMsg from {msg.From.Shorten()} for block {InputMsg.Block.Hash.Shorten()} verification failed.");
                    return(false);
                }
            }

            // check for valid validators
            if (!CheckSenderValid(msg.From))
            {
                return(false);
            }

            OutputMsgs.Add(msg);
            return(true);
        }
예제 #2
0
        public bool AddAuthResult(AuthorizedMsg msg)
        {
            // check repeated message
            if (OutputMsgs.ToList().Any(a => a.From == msg.From))
            {
                return(false);
            }

            OutputMsgs.Add(msg);
            return(true);
        }
예제 #3
0
        private ConsensusResult CheckAuthorizedResults()
        {
            var AuthMsgList = OutputMsgs.ToList();
            var ok          = AuthMsgList.Count(a => a.IsSuccess);

            if (ok >= WinNumber)
            {
                return(ConsensusResult.Yay);
            }

            var notok = AuthMsgList.Count(a => !a.IsSuccess);

            if (notok >= WinNumber)
            {
                return(ConsensusResult.Nay);
            }

            return(ConsensusResult.Uncertain);
        }
예제 #4
0
        private ConsensusResult CheckAuthorizedResults()
        {
            var AuthMsgList = OutputMsgs.ToList();
            var ok          = AuthMsgList.Count(a => a.IsSuccess);

            if (ok >= WinNumber)
            {
                return(ConsensusResult.Yea);
            }

            var notok = AuthMsgList.Count(a => !a.IsSuccess);

            if (notok >= WinNumber)
            {
                return(ConsensusResult.Nay);
            }

            _log.LogInformation($"msg count: {AuthMsgList.Count} Win Number: {WinNumber}");
            return(ConsensusResult.Uncertain);
        }