vote.rs 1017 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. use std::io;
  2. use crate::{
  3. crypto::{address::Address, 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 the Streamlet consensus
  9. #[derive(Debug, Clone, PartialEq, Eq, SerialDecodable, SerialEncodable)]
  10. pub struct Vote {
  11. /// Node public key
  12. pub public_key: PublicKey,
  13. /// Block signature
  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 slot: u64,
  19. /// Node wallet address
  20. pub address: Address,
  21. }
  22. impl Vote {
  23. pub fn new(
  24. public_key: PublicKey,
  25. vote: Signature,
  26. proposal: blake3::Hash,
  27. slot: u64,
  28. address: Address,
  29. ) -> Self {
  30. Self { public_key, vote, proposal, slot, address }
  31. }
  32. }
  33. impl net::Message for Vote {
  34. fn name() -> &'static str {
  35. "vote"
  36. }
  37. }
  38. impl_vec!(Vote);