Revision 55d723870882512d1a0ba9709129ce3227446e2e authored by Dev Ojha on 16 January 2019, 21:03:19 UTC, committed by Ethan Buchman on 16 January 2019, 21:03:19 UTC
* Add comment to simple_merkle get_split_point

* fix grammar error
1 parent 4a037f9
Raw File
test_util.go
package types

import (
	tmtime "github.com/tendermint/tendermint/types/time"
)

func MakeCommit(blockID BlockID, height int64, round int,
	voteSet *VoteSet,
	validators []PrivValidator) (*Commit, error) {

	// all sign
	for i := 0; i < len(validators); i++ {
		addr := validators[i].GetPubKey().Address()
		vote := &Vote{
			ValidatorAddress: addr,
			ValidatorIndex:   i,
			Height:           height,
			Round:            round,
			Type:             PrecommitType,
			BlockID:          blockID,
			Timestamp:        tmtime.Now(),
		}

		_, err := signAddVote(validators[i], vote, voteSet)
		if err != nil {
			return nil, err
		}
	}

	return voteSet.MakeCommit(), nil
}

func signAddVote(privVal PrivValidator, vote *Vote, voteSet *VoteSet) (signed bool, err error) {
	err = privVal.SignVote(voteSet.ChainID(), vote)
	if err != nil {
		return false, err
	}
	return voteSet.AddVote(vote)
}
back to top