You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
868 B

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. package types
  2. import (
  3. tmtime "github.com/tendermint/tendermint/types/time"
  4. )
  5. func MakeCommit(blockID BlockID, height int64, round int,
  6. voteSet *VoteSet,
  7. validators []PrivValidator) (*Commit, error) {
  8. // all sign
  9. for i := 0; i < len(validators); i++ {
  10. vote := &Vote{
  11. ValidatorAddress: validators[i].GetAddress(),
  12. ValidatorIndex: i,
  13. Height: height,
  14. Round: round,
  15. Type: PrecommitType,
  16. BlockID: blockID,
  17. Timestamp: tmtime.Now(),
  18. }
  19. _, err := signAddVote(validators[i], vote, voteSet)
  20. if err != nil {
  21. return nil, err
  22. }
  23. }
  24. return voteSet.MakeCommit(), nil
  25. }
  26. func signAddVote(privVal PrivValidator, vote *Vote, voteSet *VoteSet) (signed bool, err error) {
  27. err = privVal.SignVote(voteSet.ChainID(), vote)
  28. if err != nil {
  29. return false, err
  30. }
  31. return voteSet.AddVote(vote)
  32. }