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.

35 lines
803 B

11 years ago
  1. package blocks
  2. import (
  3. . "github.com/tendermint/tendermint/binary"
  4. "io"
  5. )
  6. /*
  7. The full vote structure is only needed when presented as evidence.
  8. Typically only the signature is passed around, as the hash & height are implied.
  9. */
  10. type Vote struct {
  11. Height UInt64
  12. BlockHash ByteSlice
  13. Signature
  14. }
  15. func ReadVote(r io.Reader) Vote {
  16. return Vote{
  17. Height: ReadUInt64(r),
  18. BlockHash: ReadByteSlice(r),
  19. Signature: ReadSignature(r),
  20. }
  21. }
  22. func (self Vote) WriteTo(w io.Writer) (n int64, err error) {
  23. var n_ int64
  24. n_, err = self.Height.WriteTo(w)
  25. n += n_; if err != nil { return n, err }
  26. n_, err = self.BlockHash.WriteTo(w)
  27. n += n_; if err != nil { return n, err }
  28. n_, err = self.Signature.WriteTo(w)
  29. n += n_; return
  30. }