saturn_mempool_oracle/
mempool_entry.rs1use std::fmt;
2
3use borsh::{BorshDeserialize, BorshSerialize};
4use serde::{Deserialize, Serialize};
5
6use crate::txid::Txid;
7
8#[repr(C)]
13#[derive(
14 Default,
15 BorshSerialize,
16 BorshDeserialize,
17 Serialize,
18 Deserialize,
19 Clone,
20 PartialEq,
21 Eq,
22 Copy,
23 Hash,
24)]
25#[serde(rename_all = "camelCase")]
26pub struct MempoolEntry {
27 pub txid: Txid, pub total_fee: u64, pub total_vsize: u64, pub descendants: u16, pub ancestors: u16, }
37
38impl fmt::Display for MempoolEntry {
39 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
40 write!(
41 f,
42 "txid: {}, total_fee: {}, total_vsize: {}, descendants: {}, ancestors: {}",
43 self.txid, self.total_fee, self.total_vsize, self.descendants, self.ancestors
44 )
45 }
46}
47
48impl fmt::Debug for MempoolEntry {
49 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
50 write!(f, "{}", self)
51 }
52}
53
54#[repr(C)]
55#[derive(Default, BorshSerialize, BorshDeserialize, Debug, Clone, PartialEq, Eq, Copy, Hash)]
56pub struct ReturnedMempoolEntry {
57 pub total_fee: u64,
58 pub total_vsize: u64,
59 pub descendants: u16,
60 pub ancestors: u16,
61}
62
63impl From<MempoolEntry> for ReturnedMempoolEntry {
64 fn from(entry: MempoolEntry) -> Self {
65 Self {
66 total_fee: entry.total_fee,
67 total_vsize: entry.total_vsize,
68 descendants: entry.descendants,
69 ancestors: entry.ancestors,
70 }
71 }
72}