use crate::{
    crypto::{address::Address, schnorr::Signature},
    net,
    util::serial::{SerialDecodable, SerialEncodable},
};

/// This struct represents a `Vote` used by the Streamlet consensus
#[derive(Debug, Clone, PartialEq, Eq, SerialDecodable, SerialEncodable)]
pub struct Vote {
    /// Block signature
    pub vote: Signature,
    /// Block proposal hash to vote on
    pub proposal: blake3::Hash,
    /// Slot uid, generated by the beacon
    pub slot: u64,
    /// Node wallet address
    pub address: Address,
}

impl Vote {
    pub fn new(vote: Signature, proposal: blake3::Hash, slot: u64, address: Address) -> Self {
        Self { vote, proposal, slot, address }
    }
}

impl net::Message for Vote {
    fn name() -> &'static str {
        "vote"
    }
}
