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.

41 lines
936 B

  1. package consensus
  2. import (
  3. "fmt"
  4. . "github.com/tendermint/tendermint/config"
  5. )
  6. func GenVoteDocument(voteType byte, height uint32, round uint16, proposalHash []byte) string {
  7. stepName := ""
  8. switch voteType {
  9. case VoteTypeBare:
  10. stepName = "bare"
  11. case VoteTypePrecommit:
  12. stepName = "precommit"
  13. case VoteTypeCommit:
  14. stepName = "commit"
  15. default:
  16. panic("Unknown vote type")
  17. }
  18. return fmt.Sprintf(
  19. `-----BEGIN TENDERMINT DOCUMENT-----
  20. URI: %v://consensus/%v/%v/%v
  21. ProposalHash: %X
  22. -----END TENDERMINT DOCUMENHT-----`,
  23. Config.Network, height, round, stepName,
  24. proposalHash,
  25. )
  26. }
  27. func GenBlockPartDocument(height uint32, round uint16, index uint16, total uint16, blockPartHash []byte) string {
  28. return fmt.Sprintf(
  29. `-----BEGIN TENDERMINT DOCUMENT-----
  30. URI: %v://blockpart/%v/%v/%v
  31. Total: %v
  32. BlockPartHash: %X
  33. -----END TENDERMINT DOCUMENHT-----`,
  34. Config.Network, height, round, index,
  35. total,
  36. blockPartHash,
  37. )
  38. }