mempool/backend/rust-gbt/src/audit_transaction.rs

58 lines
1.3 KiB
Rust
Raw Normal View History

2023-06-23 20:41:39 -04:00
use std::{
cmp::Ordering,
collections::HashSet,
hash::{Hash, Hasher},
};
2023-06-23 16:42:58 -04:00
#[derive(Clone)]
pub struct AuditTransaction {
2023-06-23 20:41:39 -04:00
pub uid: u32,
pub fee: u64,
pub weight: u32,
pub sigops: u32,
pub fee_per_vsize: f64,
pub effective_fee_per_vsize: f64,
pub dependency_rate: f64,
pub inputs: Vec<u32>,
pub relatives_set_flag: bool,
pub ancestors: HashSet<u32>,
pub children: HashSet<u32>,
pub ancestor_fee: u64,
pub ancestor_weight: u32,
pub ancestor_sigops: u32,
pub score: f64,
pub used: bool,
pub modified: bool,
pub dirty: bool,
2023-06-23 16:42:58 -04:00
}
impl Hash for AuditTransaction {
2023-06-23 20:41:39 -04:00
fn hash<H: Hasher>(&self, state: &mut H) {
self.uid.hash(state);
}
2023-06-23 16:42:58 -04:00
}
impl PartialEq for AuditTransaction {
2023-06-23 20:41:39 -04:00
fn eq(&self, other: &Self) -> bool {
self.uid == other.uid
}
2023-06-23 16:42:58 -04:00
}
impl Eq for AuditTransaction {}
impl PartialOrd for AuditTransaction {
2023-06-23 20:41:39 -04:00
fn partial_cmp(&self, other: &AuditTransaction) -> Option<Ordering> {
if self.score == other.score {
2023-06-23 21:51:03 -07:00
Some(self.uid.cmp(&other.uid))
2023-06-23 20:41:39 -04:00
} else {
2023-06-23 21:51:03 -07:00
self.score.partial_cmp(&other.score)
2023-06-23 20:41:39 -04:00
}
2023-06-23 16:42:58 -04:00
}
}
impl Ord for AuditTransaction {
2023-06-23 20:41:39 -04:00
fn cmp(&self, other: &AuditTransaction) -> Ordering {
self.partial_cmp(other).unwrap()
}
}