Пример #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;
        }
Пример #2
0
 public void AddCommitedResult(AuthorizerCommitMsg msg)
 {
     CommitMsgs.Add(msg);
     if (CommitMsgs.Count() >= ProtocolSettings.Default.ConsensusNumber)
     {
         Settled = true;
         Done.Set();
     }
 }
Пример #3
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);
        }
Пример #4
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);
        }
Пример #5
0
 public void Reset()
 {
     _localResult = null;
     OutputMsgs.Clear();
     CommitMsgs.Clear();
 }