vote.rs 948 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. use std::io;
  2. use darkfi::{
  3. crypto::{keypair::PublicKey, schnorr::Signature},
  4. impl_vec, net,
  5. util::serial::{Decodable, Encodable, SerialDecodable, SerialEncodable, VarInt},
  6. Result,
  7. };
  8. /// This struct represents a Vote, used by Streamlet consensus.
  9. #[derive(Debug, Clone, PartialEq, SerialDecodable, SerialEncodable)]
  10. pub struct Vote {
  11. /// Node public key
  12. pub public_key: PublicKey,
  13. /// signed block
  14. pub vote: Signature,
  15. /// block proposal hash to vote on
  16. pub proposal: blake3::Hash,
  17. /// Slot uid, generated by the beacon
  18. pub sl: u64,
  19. /// node id
  20. pub id: u64,
  21. }
  22. impl Vote {
  23. pub fn new(
  24. public_key: PublicKey,
  25. vote: Signature,
  26. proposal: blake3::Hash,
  27. sl: u64,
  28. id: u64,
  29. ) -> Vote {
  30. Vote { public_key, vote, proposal, sl, id }
  31. }
  32. }
  33. impl net::Message for Vote {
  34. fn name() -> &'static str {
  35. "vote"
  36. }
  37. }
  38. impl_vec!(Vote);