func (pv *FridayFilePV) signProposal(chainID string, proposal *types.Proposal) error {
	height, round, step := proposal.Height, proposal.Round, stepPropose

	sameHRS, existSignState, err := pv.SignState.CheckHRS(height, round, step)
	if err != nil {
		return err
	}

	signBytes := proposal.SignBytes(chainID)

	// We might crash before writing to the wal,
	// causing us to try to re-sign for the same HRS.
	// If signbytes are the same, use the last signature.
	// If they only differ by timestamp, use last timestamp and signature
	// Otherwise, return error
	if sameHRS {
		if bytes.Equal(signBytes, existSignState.SignBytes) {
			proposal.Signature = existSignState.Signature
		} else if timestamp, ok := checkProposalsOnlyDifferByTimestamp(existSignState.SignBytes, signBytes); ok {
			proposal.Timestamp = timestamp
			proposal.Signature = existSignState.Signature
		} else {
			err = fmt.Errorf("conflicting data")
		}
		return err
	}

	// It passed the checks. Sign the proposal
	sig, err := pv.Key.PrivKey.Sign(signBytes)
	if err != nil {
		return err
	}
	pv.saveSigned(height, round, step, signBytes, sig)
	proposal.Signature = sig
	return nil
}
// signProposal checks if the proposal is good to sign and sets the proposal signature.
// It may need to set the timestamp as well if the proposal is otherwise the same as
// a previously signed proposal ie. we crashed after signing but before the proposal hit the WAL).
signProposal checks if the proposal is good to sign and sets the proposal signature.
It may need to set the timestamp as well if the proposal is otherwise the same as
a previously signed proposal ie. we crashed after signing but before the proposal hit the WAL).
// signProposal checks if the proposal is good to sign and sets the proposal signature . // It may need to set the timestamp as well if the proposal is otherwise the same as // a previously signed proposal ie . we crashed after signing but before the proposal hit the WAL ) .
func (pv *FridayFilePV) signProposal(chainID string, proposal *types.Proposal) error {
	height, round, step := proposal.Height, proposal.Round, stepPropose
	sameHRS, existSignState, err := pv.SignState.CheckHRS(height, round, step)
	if err != nil {
		return err
	}
	signBytes := proposal.SignBytes(chainID)
	if sameHRS {
		if bytes.Equal(signBytes, existSignState.SignBytes) {
			proposal.Signature = existSignState.Signature
		} else if timestamp, ok := checkProposalsOnlyDifferByTimestamp(existSignState.SignBytes, signBytes); ok {
			proposal.Timestamp = timestamp
			proposal.Signature = existSignState.Signature
		} else {
			err = fmt.Errorf("conflicting data")
		}
		return err
	}
	sig, err := pv.Key.PrivKey.Sign(signBytes)
	if err != nil {
		return err
	}
	pv.saveSigned(height, round, step, signBytes, sig)
	proposal.Signature = sig
	return nil
}
func ( pv * FridayFilePV ) signProposal ( chainID string , proposal * types . Proposal ) error { height , round , step := proposal . Height , proposal . Round , stepPropose sameHRS , existSignState , err := pv . SignState . CheckHRS ( height , round , step ) if err != nil { return err } signBytes := proposal . SignBytes ( chainID ) if sameHRS { if bytes . Equal ( signBytes , existSignState . SignBytes ) { proposal . Signature = existSignState . Signature } else if timestamp , ok := checkProposalsOnlyDifferByTimestamp ( existSignState . SignBytes , signBytes ) ; ok { proposal . Timestamp = timestamp proposal . Signature = existSignState . Signature } else { err = fmt . Errorf ( " " ) } return err } sig , err := pv . Key . PrivKey . Sign ( signBytes ) if err != nil { return err } pv . saveSigned ( height , round , step , signBytes , sig ) proposal . Signature = sig return nil }
signProposal checks if the proposal is good to sign and sets the proposal signature.
signProposal checks if the proposal is good to sign and sets the proposal signature .
// We might crash before writing to the wal, // causing us to try to re-sign for the same HRS. // If signbytes are the same, use the last signature. // If they only differ by timestamp, use last timestamp and signature // Otherwise, return error // It passed the checks. Sign the proposal