zebra_node_services/mempool/
gossip.rs1use zebra_chain::transaction::{UnminedTx, UnminedTxId};
4
5#[derive(Clone, Debug, Eq, PartialEq)]
7pub enum Gossip {
8 Id(UnminedTxId),
10
11 Tx(UnminedTx),
13}
14
15impl Gossip {
16 pub fn id(&self) -> UnminedTxId {
18 match self {
19 Gossip::Id(txid) => *txid,
20 Gossip::Tx(tx) => tx.id,
21 }
22 }
23
24 pub fn tx(&self) -> Option<UnminedTx> {
26 match self {
27 Gossip::Id(_) => None,
28 Gossip::Tx(tx) => Some(tx.clone()),
29 }
30 }
31}
32
33impl From<UnminedTxId> for Gossip {
34 fn from(txid: UnminedTxId) -> Self {
35 Gossip::Id(txid)
36 }
37}
38
39impl From<UnminedTx> for Gossip {
40 fn from(tx: UnminedTx) -> Self {
41 Gossip::Tx(tx)
42 }
43}