use zebra_chain::transaction::{UnminedTx, UnminedTxId};
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum Gossip {
Id(UnminedTxId),
Tx(UnminedTx),
}
impl Gossip {
pub fn id(&self) -> UnminedTxId {
match self {
Gossip::Id(txid) => *txid,
Gossip::Tx(tx) => tx.id,
}
}
pub fn tx(&self) -> Option<UnminedTx> {
match self {
Gossip::Id(_) => None,
Gossip::Tx(tx) => Some(tx.clone()),
}
}
}
impl From<UnminedTxId> for Gossip {
fn from(txid: UnminedTxId) -> Self {
Gossip::Id(txid)
}
}
impl From<UnminedTx> for Gossip {
fn from(tx: UnminedTx) -> Self {
Gossip::Tx(tx)
}
}