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.

42 lines
834 B

  1. package factory
  2. import (
  3. "context"
  4. "time"
  5. tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
  6. "github.com/tendermint/tendermint/types"
  7. )
  8. func MakeVote(
  9. val types.PrivValidator,
  10. chainID string,
  11. valIndex int32,
  12. height int64,
  13. round int32,
  14. step int,
  15. blockID types.BlockID,
  16. time time.Time,
  17. ) (*types.Vote, error) {
  18. pubKey, err := val.GetPubKey(context.Background())
  19. if err != nil {
  20. return nil, err
  21. }
  22. v := &types.Vote{
  23. ValidatorAddress: pubKey.Address(),
  24. ValidatorIndex: valIndex,
  25. Height: height,
  26. Round: round,
  27. Type: tmproto.SignedMsgType(step),
  28. BlockID: blockID,
  29. Timestamp: time,
  30. }
  31. vpb := v.ToProto()
  32. err = val.SignVote(context.Background(), chainID, vpb)
  33. if err != nil {
  34. panic(err)
  35. }
  36. v.Signature = vpb.Signature
  37. return v, nil
  38. }