Example #1
0
func (fs *FaultState) SigTally(state interfaces.IState) int {
	validSigCount := 0
	cb, err := fs.FaultCore.MarshalCore()
	if err != nil {
		return validSigCount
	}
	for _, fedSig := range fs.VoteMap {
		check, err := state.FastVerifyAuthoritySignature(cb, fedSig, fs.FaultCore.DBHeight)
		if err == nil && check == 1 {
			validSigCount++
		}

	}
	return validSigCount
}
Example #2
0
// Validate the message, given the state.  Three possible results:
//  < 0 -- Message is invalid.  Discard
//  0   -- Cannot tell if message is Valid
//  1   -- Message is valid
func (m *FullServerFault) Validate(state interfaces.IState) int {
	// Check main signature
	bytes, err := m.MarshalForSignature()
	if err != nil {
		return -1
	}
	//sig := m.Signature.GetSignature()

	//sfSigned, err := state.VerifyAuthoritySignature(bytes, sig, m.DBHeight)
	sfSigned, err := state.FastVerifyAuthoritySignature(bytes, m.Signature, m.DBHeight)
	if err != nil {
		return -1
	}
	if sfSigned < 1 {
		return -1
	}
	_, err = m.MarshalCore()
	if err != nil {
		return -1
	}

	/*
		sht := state.GetSystemHeight(m.DBHeight)
		if sht < 0 {
			return 0
		}

		if sht >= int(m.Height) {
			return -1
		}

		if sht < int(m.Height) {
			return 0
		}

		if state.GetLLeaderHeight() < m.DBHeight {
			return 0
		}

		if state.GetLLeaderHeight() > m.DBHeight {
			return -1
		}
	*/

	return 1
}