cfxcore/pos/mempool/core_mempool/
transaction.rs1use diem_crypto::HashValue;
9use diem_types::{
10 account_address::AccountAddress,
11 transaction::{GovernanceRole, SignedTransaction},
12};
13use serde::{Deserialize, Serialize};
14use std::time::Duration;
15
16#[derive(Clone)]
17pub struct MempoolTransaction {
18 pub txn: SignedTransaction,
19 pub expiration_time: Duration,
22 pub ranking_score: u64,
23 pub timeline_state: TimelineState,
24 pub governance_role: GovernanceRole,
25}
26
27impl MempoolTransaction {
28 pub(crate) fn new(
29 txn: SignedTransaction, expiration_time: Duration, ranking_score: u64,
30 timeline_state: TimelineState, governance_role: GovernanceRole,
31 ) -> Self {
32 Self {
33 txn,
34 ranking_score,
35 expiration_time,
36 timeline_state,
37 governance_role,
38 }
39 }
40
41 pub(crate) fn get_hash(&self) -> HashValue { self.txn.hash() }
42
43 pub(crate) fn get_sender(&self) -> AccountAddress { self.txn.sender() }
44}
45
46#[derive(Clone, Copy, PartialEq, Eq, Debug, Deserialize, Hash, Serialize)]
47pub enum TimelineState {
48 Ready(u64),
52 NotReady,
55 NonQualified,
58}