kabu_types_blockchain/
mempool_tx.rs

1use alloy_primitives::{BlockNumber, TxHash};
2use chrono::{DateTime, Utc};
3
4use crate::FetchState;
5use crate::{KabuDataTypes, KabuDataTypesEthereum};
6
7#[derive(Clone, Debug)]
8pub struct MempoolTx<D: KabuDataTypes> {
9    pub source: String,
10    pub tx_hash: TxHash,
11    pub time: DateTime<Utc>,
12    pub tx: Option<D::Transaction>,
13    pub logs: Option<Vec<D::Log>>,
14    pub mined: Option<BlockNumber>,
15    pub failed: Option<bool>,
16    pub state_update: Option<D::StateUpdate>,
17    pub pre_state: Option<FetchState<D::StateUpdate>>,
18}
19
20impl MempoolTx<KabuDataTypesEthereum> {
21    pub fn new() -> MempoolTx<KabuDataTypesEthereum> {
22        MempoolTx { ..MempoolTx::default() }
23    }
24    pub fn new_with_hash(tx_hash: TxHash) -> MempoolTx<KabuDataTypesEthereum> {
25        MempoolTx { tx_hash, ..MempoolTx::default() }
26    }
27}
28
29impl<LDT: KabuDataTypes> Default for MempoolTx<LDT> {
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}