use extended_primitives::Hash;
use handshake_types::Compact;
use serde_tuple::*;
use stratum_types::traits::Notify as NotifyTrait;

// #[derive(Clone, Debug, Deserialize, Serialize, Default)]
#[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug, Default)]
pub struct Notify {
    pub job_id: String,
    pub prev_block: Hash,
    pub merkle_root: Hash,
    pub witness_root: Hash,
    pub tree_root: Hash,
    pub reserved_root: Hash,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mask_hash: Option<Hash>,
    pub version: u32,
    pub bits: u32,
    pub time: u64,
}

//@todo manually do the serialize for this, and reorder for non-classic handyminer.

impl NotifyTrait for Notify {
    fn get_difficulty(&self) -> f64 {
        Compact::from(self.bits).to_f64()
    }
}
