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); }
public bool AddAuthResult(AuthorizedMsg msg) { // check repeated message if (OutputMsgs.ToList().Any(a => a.From == msg.From)) { return(false); } OutputMsgs.Add(msg); return(true); }
public APIResultCodes GetMajorErrorCode() { var q = OutputMsgs.GroupBy(a => a.Result) .Select(g => new { g.Key, Count = g.Count() }) .OrderByDescending(x => x.Count); if (q.Any()) { return(q.First().Key); } else { return(APIResultCodes.UnknownError); } }
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); }
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); }
public void Reset() { _localResult = null; OutputMsgs.Clear(); CommitMsgs.Clear(); }
public void AddAuthResult(AuthorizedMsg msg) { OutputMsgs.Add(msg); }