public void AddCommitedResult(AuthorizerCommitMsg msg) { CommitMsgs.Add(msg); if (CommitMsgs.Count() >= ProtocolSettings.Default.ConsensusNumber) { Settled = true; Done.Set(); } }
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); }