// regularFaultExecution will create a FaultState in our FaultMap (if none exists already) // and save the signature of this particular ServerFault to that FaultStat's VoteMap func (s *State) regularFaultExecution(sf *messages.ServerFault, pl *ProcessList) { var issuerID [32]byte rawIssuerID := sf.GetSignature().GetKey() for i := 0; i < 32; i++ { if i < len(rawIssuerID) { issuerID[i] = rawIssuerID[i] } } coreHash := sf.GetCoreHash().Fixed() faultState := pl.GetFaultState(coreHash) if faultState.IsNil() { // We don't have a map entry yet; let's create one fcore := ExtractFaultCore(sf) faultState = FaultState{FaultCore: fcore, AmINegotiator: false, MyVoteTallied: false, VoteMap: make(map[[32]byte]interfaces.IFullSignature)} if isMyNegotiation(fcore, pl) { faultState.AmINegotiator = true pl.AmINegotiator = true } if faultState.VoteMap == nil { faultState.VoteMap = make(map[[32]byte]interfaces.IFullSignature) } pl.AddFaultState(coreHash, faultState) } lbytes, err := sf.MarshalForSignature() sfSig := sf.Signature.GetSignature() isPledge := false auth, _ := s.GetAuthority(sf.AuditServerID) if auth == nil { isPledge = false } else { valid, err := auth.VerifySignature(lbytes, sfSig) if err == nil && valid { isPledge = true faultState.PledgeDone = true } } sfSigned, err := s.FastVerifyAuthoritySignature(lbytes, sf.Signature, sf.DBHeight) if err == nil && (sfSigned > 0 || (sfSigned == 0 && isPledge)) { faultState.VoteMap[issuerID] = sf.GetSignature() } if s.Leader || s.IdentityChainID.IsSameAs(sf.AuditServerID) { if !faultState.MyVoteTallied { now := time.Now().Unix() if now-faultState.LastMatch > 3 { if int(now-s.LastTiebreak) > s.FaultTimeout/2 { if faultState.SigTally(s) >= len(pl.FedServers)-1 { s.LastTiebreak = now } s.matchFault(sf) faultState.LastMatch = now } } } } // Update the FaultState in our FaultMap with any updates that were applied // during execution of this function pl.AddFaultState(coreHash, faultState) }