Esempio n. 1
0
        private ConsensusResult CheckCommitedResults()
        {
            var CommitMsgList = CommitMsgs.ToList();
            var ok            = CommitMsgList.Count(a => a.Consensus == ConsensusResult.Yay);

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

            var notok = CommitMsgList.Count(a => a.Consensus == ConsensusResult.Nay);

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

            return(ConsensusResult.Uncertain);
            //var CommitMsgList = CommitMsgs.ToList();
            //if (CommitMsgList.Count(a => a.Consensus == ConsensusResult.Yay) >= WinNumber
            //    || CommitMsgList.Count(a => a.Consensus == ConsensusResult.Nay) >= WinNumber)
            //{
            //    _log.LogInformation($"Committed: {ConsensusUIndex}/{InputMsg.Block.Index} Yay: {CommitMsgs.Count(a => a.Consensus == ConsensusResult.Yay)} of {CommitMsgs.Select(a => a.From.Shorten()).Aggregate((x, y) => x + ", " + y)}");
            //    return true;
            //    //Settled = true;
            //    //Done.Set();
            //}
            //else
            //    return false;
        }
Esempio n. 2
0
        public bool AddCommitedResult(AuthorizerCommitMsg msg)
        {
            //_log.LogInformation($"Commit msg from: {msg.From.Shorten()}");
            // check repeated message
            if (CommitMsgs.ToList().Any(a => a.From == msg.From))
            {
                return(false);
            }

            // check network state
            // !! only accept from svcBlock ( or associated view )
            // check for valid validators
            if (!CheckSenderValid(msg.From))
            {
                return(false);
            }

            CommitMsgs.Add(msg);

            return(true);
        }
Esempio n. 3
0
        public bool AddCommitedResult(AuthorizerCommitMsg msg)
        {
            _log.LogInformation($"Commit msg from: {msg.From}");
            // check repeated message
            if (CommitMsgs.ToList().Any(a => a.From == msg.From))
            {
                return(false);
            }

            CommitMsgs.Add(msg);

            var CommitMsgList = CommitMsgs.ToList();

            if (CommitMsgList.Count(a => a.Consensus == ConsensusResult.Yay) >= ProtocolSettings.Default.ConsensusWinNumber ||
                CommitMsgList.Count(a => a.Consensus == ConsensusResult.Nay) >= ProtocolSettings.Default.ConsensusWinNumber)
            {
                _log.LogInformation($"Committed: {ConsensusUIndex}/{InputMsg.Block.Index} Yay: {CommitMsgs.Count(a => a.Consensus == ConsensusResult.Yay)} of {CommitMsgs.Select(a => a.From.Shorten()).Aggregate((x, y) => x + ", " + y)}");
                Settled = true;
                Done.Set();
            }
            return(true);
        }