1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
use diem_types::{
account_address::AccountAddress,
account_config::AccountSequenceInfo,
transaction::{GovernanceRole, SignedTransaction},
};
use serde::{Deserialize, Serialize};
use std::time::Duration;
#[derive(Clone, Debug)]
pub struct MempoolTransaction {
pub txn: SignedTransaction,
pub expiration_time: Duration,
pub gas_amount: u64,
pub ranking_score: u64,
pub timeline_state: TimelineState,
pub governance_role: GovernanceRole,
pub sequence_info: SequenceInfo,
}
impl MempoolTransaction {
pub(crate) fn new(
txn: SignedTransaction,
expiration_time: Duration,
gas_amount: u64,
ranking_score: u64,
timeline_state: TimelineState,
governance_role: GovernanceRole,
seqno_type: AccountSequenceInfo,
) -> Self {
Self {
sequence_info: SequenceInfo {
transaction_sequence_number: txn.sequence_number(),
account_sequence_number_type: seqno_type,
},
txn,
expiration_time,
gas_amount,
ranking_score,
timeline_state,
governance_role,
}
}
pub(crate) fn get_sender(&self) -> AccountAddress {
self.txn.sender()
}
pub(crate) fn get_gas_price(&self) -> u64 {
self.txn.gas_unit_price()
}
}
#[derive(Clone, Copy, PartialEq, Eq, Debug, Deserialize, Hash, Serialize)]
pub enum TimelineState {
Ready(u64),
NotReady,
NonQualified,
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub struct SequenceInfo {
pub transaction_sequence_number: u64,
pub account_sequence_number_type: AccountSequenceInfo,
}