kabu_types_blockchain/
mempool_tx.rs

1use crate::{FetchState, GethStateUpdate};
2use alloy_primitives::{BlockNumber, TxHash};
3use alloy_rpc_types_eth::Log;
4use chrono::{DateTime, Utc};
5use reth_node_types::NodePrimitives;
6
7#[derive(Clone, Debug)]
8pub struct MempoolTx<N: NodePrimitives> {
9    pub source: String,
10    pub tx_hash: TxHash,
11    pub time: DateTime<Utc>,
12    pub tx: Option<N::SignedTx>,
13    pub logs: Option<Vec<Log>>,
14    pub mined: Option<BlockNumber>,
15    pub failed: Option<bool>,
16    pub state_update: Option<GethStateUpdate>,
17    pub pre_state: Option<FetchState<GethStateUpdate>>,
18}
19
20impl<N: NodePrimitives> MempoolTx<N> {
21    pub fn new() -> MempoolTx<N> {
22        MempoolTx { ..MempoolTx::default() }
23    }
24    pub fn new_with_hash(tx_hash: TxHash) -> MempoolTx<N> {
25        MempoolTx { tx_hash, ..MempoolTx::default() }
26    }
27}
28
29impl<N: NodePrimitives> Default for MempoolTx<N> {
30    fn default() -> Self {
31        MempoolTx {
32            source: "unknown".to_string(),
33            tx_hash: TxHash::default(),
34            time: Utc::now(),
35            tx: None,
36            state_update: None,
37            logs: None,
38            mined: None,
39            failed: None,
40            pre_state: None,
41        }
42    }
43}