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.

44 lines
830 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. ctx context.Context,
  10. val types.PrivValidator,
  11. chainID string,
  12. valIndex int32,
  13. height int64,
  14. round int32,
  15. step int,
  16. blockID types.BlockID,
  17. time time.Time,
  18. ) (*types.Vote, error) {
  19. pubKey, err := val.GetPubKey(ctx)
  20. if err != nil {
  21. return nil, err
  22. }
  23. v := &types.Vote{
  24. ValidatorAddress: pubKey.Address(),
  25. ValidatorIndex: valIndex,
  26. Height: height,
  27. Round: round,
  28. Type: tmproto.SignedMsgType(step),
  29. BlockID: blockID,
  30. Timestamp: time,
  31. }
  32. vpb := v.ToProto()
  33. if err := val.SignVote(ctx, chainID, vpb); err != nil {
  34. return nil, err
  35. }
  36. v.Signature = vpb.Signature
  37. return v, nil
  38. }