cfx_packing_pool/
mock_tx.rs1use crate::transaction::PackingPoolTransaction;
2
3#[derive(Default, Clone, Copy, PartialEq, Eq, Debug, Hash)]
4pub struct MockTransaction {
7 pub id: usize,
8 pub sender: u64,
9 pub nonce: u64,
10 pub gas_price: u64,
11 pub gas_limit: u64,
12}
13
14impl PartialOrd for MockTransaction {
15 fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
16 Some(self.cmp(other))
17 }
18}
19
20impl Ord for MockTransaction {
21 fn cmp(&self, other: &Self) -> std::cmp::Ordering { self.id.cmp(&other.id) }
22}
23
24impl PackingPoolTransaction for MockTransaction {
25 type Sender = u64;
26
27 fn sender(&self) -> Self::Sender { self.sender }
28
29 fn nonce(&self) -> cfx_types::U256 { self.nonce.into() }
30
31 fn gas_price(&self) -> cfx_types::U256 { self.gas_price.into() }
32
33 fn gas_limit(&self) -> cfx_types::U256 { self.gas_limit.into() }
34
35 fn hash(&self) -> cfx_types::H256 {
36 cfx_types::H256::from_low_u64_be(self.id as u64)
37 }
38}