kabu_types_blockchain/
accountnoncetx.rs

1use alloy_primitives::TxHash;
2
3#[derive(Debug, Clone, Default)]
4pub struct AccountNonceAndTransactions {
5    pub nonce: Option<u64>,
6    pub txs: Vec<TxHash>,
7}
8
9impl AccountNonceAndTransactions {
10    pub fn new() -> Self {
11        Self::default()
12    }
13
14    pub fn add_tx_hash(&mut self, tx_hash: TxHash) -> &mut Self {
15        self.txs.push(tx_hash);
16        self
17    }
18
19    pub fn set_nonce(&mut self, nonce: Option<u64>) -> &mut Self {
20        if let Some(cur_nonce) = self.nonce {
21            if let Some(some_nonce) = nonce {
22                if cur_nonce < some_nonce {
23                    self.nonce = Some(some_nonce);
24                }
25                return self;
26            }
27        }
28        self.nonce = nonce;
29        self
30    }
31}