fuel_core_p2p/gossipsub/
messages.rs

1use crate::ports::P2PPreConfirmationMessage;
2use fuel_core_types::fuel_tx::Transaction;
3use serde::{
4    Deserialize,
5    Serialize,
6};
7use std::sync::Arc;
8
9/// Used to inform `GossipsubCodec` to which GossipsubMessage decode to
10/// GossipTopicTag is decided by checking received TopicHash from the peer
11#[derive(Debug, Clone, Copy, Eq, PartialEq)]
12pub enum GossipTopicTag {
13    NewTx,
14    TxPreconfirmations,
15}
16
17/// Takes `Arc<T>` and wraps it in a matching GossipsubBroadcastRequest
18/// The inner referenced value is serialized and broadcast to the network
19/// It is deserialized as `GossipsubMessage`
20#[derive(Debug, Clone)]
21pub enum GossipsubBroadcastRequest {
22    NewTx(Arc<Transaction>),
23    TxPreConfirmations(Arc<P2PPreConfirmationMessage>),
24}
25
26#[allow(clippy::large_enum_variant)]
27#[derive(Serialize, Deserialize, Debug, Clone)]
28pub enum GossipsubMessage {
29    NewTx(Transaction),
30    TxPreConfirmations(P2PPreConfirmationMessage),
31}