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.

46 lines
1.0 KiB

10 years ago
  1. package blocks
  2. import (
  3. "fmt"
  4. . "github.com/tendermint/tendermint/config"
  5. )
  6. func GenVoteDocument(voteType byte, height uint32, round uint16, blockHash []byte) []byte {
  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 []byte(fmt.Sprintf(
  19. `!!!!!BEGIN TENDERMINT VOTE!!!!!
  20. Network: %v
  21. Height: %v
  22. Round: %v
  23. Step: %v
  24. BlockHash: %v
  25. !!!!!END TENDERMINT VOTE!!!!!`,
  26. Config.Network, height, round, stepName, blockHash,
  27. ))
  28. }
  29. func GenProposalDocument(height uint32, round uint16, blockPartsTotal uint16, blockPartsHash []byte,
  30. polPartsTotal uint16, polPartsHash []byte) []byte {
  31. return []byte(fmt.Sprintf(
  32. `!!!!!BEGIN TENDERMINT PROPOSAL!!!!!
  33. Network: %v
  34. Height: %v
  35. Round: %v
  36. BlockPartsTotal: %v
  37. BlockPartsHash: %X
  38. POLPartsTotal: %v
  39. POLPartsHash: %X
  40. !!!!!END TENDERMINT PROPOSAL!!!!!`,
  41. Config.Network, height, round, blockPartsTotal, blockPartsHash, polPartsTotal, polPartsHash,
  42. ))
  43. }