diff --git a/binaries/cuprated/src/rpc/request/txpool.rs b/binaries/cuprated/src/rpc/request/txpool.rs index f7c0168..4c3c9d3 100644 --- a/binaries/cuprated/src/rpc/request/txpool.rs +++ b/binaries/cuprated/src/rpc/request/txpool.rs @@ -6,14 +6,17 @@ use anyhow::Error; use tower::{Service, ServiceExt}; use cuprate_helper::cast::usize_to_u64; -use cuprate_txpool::service::{ - interface::{TxpoolReadRequest, TxpoolReadResponse}, - TxpoolReadHandle, +use cuprate_txpool::{ + service::{ + interface::{TxpoolReadRequest, TxpoolReadResponse}, + TxpoolReadHandle, + }, + TxEntry, }; /// [`TxpoolReadRequest::Backlog`] -pub(super) async fn backlog(txpool_read: &mut TxpoolReadHandle) -> Result, Error> { - let TxpoolReadResponse::Backlog(backlog) = txpool_read +pub(super) async fn backlog(txpool_read: &mut TxpoolReadHandle) -> Result, Error> { + let TxpoolReadResponse::Backlog(tx_entries) = txpool_read .ready() .await .expect("TODO") @@ -24,7 +27,7 @@ pub(super) async fn backlog(txpool_read: &mut TxpoolReadHandle) -> Result), + /// The inner `Vec` contains information on all + /// the transactions currently in the pool. + Backlog(Vec), /// Response to [`TxpoolReadRequest::Size`]. /// - /// TODO + /// The inner value is the amount of + /// transactions currently in the pool. Size(usize), } diff --git a/storage/txpool/src/tx.rs b/storage/txpool/src/tx.rs new file mode 100644 index 0000000..6425326 --- /dev/null +++ b/storage/txpool/src/tx.rs @@ -0,0 +1,14 @@ +//! Transaction metadata. + +/// Data about a transaction in the pool. +/// +/// Used in [`TxpoolReadResponse::Backlog`](crate::service::interface::TxpoolReadResponse::Backlog). +#[derive(Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash)] +pub struct TxEntry { + /// The transaction's weight. + pub weight: u64, + /// The transaction's fee. + pub fee: u64, + /// How long the transaction has been in the pool. + pub time_in_pool: std::time::Duration, +}