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.

43 lines
822 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. err = val.SignVote(ctx, chainID, vpb)
  34. if err != nil {
  35. panic(err)
  36. }
  37. v.Signature = vpb.Signature
  38. return v, nil
  39. }