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 && let Some(some_nonce) = nonce
22 {
23 if cur_nonce < some_nonce {
24 self.nonce = Some(some_nonce);
25 }
26 return self;
27 }
28 self.nonce = nonce;
29 self
30 }
31}