From b30b41a4d8381f473549a877b58a1790fae6d96c Mon Sep 17 00:00:00 2001 From: "hinto.janai" Date: Wed, 30 Oct 2024 18:41:42 -0400 Subject: [PATCH] txpool: collapse `TxEntry` --- storage/txpool/src/service/interface.rs | 13 +------------ storage/txpool/src/service/read.rs | 7 ------- storage/txpool/src/tx.rs | 16 ++-------------- 3 files changed, 3 insertions(+), 33 deletions(-) diff --git a/storage/txpool/src/service/interface.rs b/storage/txpool/src/service/interface.rs index f8e2d38..a27c630 100644 --- a/storage/txpool/src/service/interface.rs +++ b/storage/txpool/src/service/interface.rs @@ -9,7 +9,7 @@ use std::{ use cuprate_types::TransactionVerificationData; use crate::{ - tx::{BlockTemplateTxEntry, TxEntry}, + tx::TxEntry, types::{KeyImage, TransactionBlobHash, TransactionHash}, }; @@ -34,12 +34,6 @@ pub enum TxpoolReadRequest { /// Get information on all transactions in the pool. Backlog, - /// Get information on all transactions in - /// the pool for block template purposes. - /// - /// This is only slightly different to [`TxpoolReadRequest::Backlog`]. - BlockTemplateBacklog, - /// Get the number of transactions in the pool. Size { /// If this is [`true`], the size returned will @@ -80,11 +74,6 @@ pub enum TxpoolReadResponse { /// the transactions currently in the pool. Backlog(Vec), - /// Response to [`TxpoolReadRequest::BlockTemplateBacklog`]. - /// - /// The inner [`Vec`] contains information on transactions - BlockTemplateBacklog(Vec), - /// Response to [`TxpoolReadRequest::Size`]. /// /// The inner value is the amount of diff --git a/storage/txpool/src/service/read.rs b/storage/txpool/src/service/read.rs index 695a48a..0de1e7d 100644 --- a/storage/txpool/src/service/read.rs +++ b/storage/txpool/src/service/read.rs @@ -71,7 +71,6 @@ fn map_request( } TxpoolReadRequest::TxsForBlock(txs_needed) => txs_for_block(env, txs_needed), TxpoolReadRequest::Backlog => backlog(env), - TxpoolReadRequest::BlockTemplateBacklog => block_template_backlog(env), TxpoolReadRequest::Size { include_sensitive_txs, } => size(env, include_sensitive_txs), @@ -202,12 +201,6 @@ fn backlog(env: &ConcreteEnv) -> ReadResponseResult { Ok(TxpoolReadResponse::Backlog(todo!())) } -/// [`TxpoolReadRequest::BlockTemplateBacklog`]. -#[inline] -fn block_template_backlog(env: &ConcreteEnv) -> ReadResponseResult { - Ok(TxpoolReadResponse::BlockTemplateBacklog(todo!())) -} - /// [`TxpoolReadRequest::Size`]. #[inline] fn size(env: &ConcreteEnv, include_sensitive_txs: bool) -> ReadResponseResult { diff --git a/storage/txpool/src/tx.rs b/storage/txpool/src/tx.rs index 03cc48c..29afae8 100644 --- a/storage/txpool/src/tx.rs +++ b/storage/txpool/src/tx.rs @@ -5,6 +5,8 @@ /// Used in [`TxpoolReadResponse::Backlog`](crate::service::interface::TxpoolReadResponse::Backlog). #[derive(Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash)] pub struct TxEntry { + /// The transaction's ID (hash). + pub id: [u8; 32], /// The transaction's weight. pub weight: u64, /// The transaction's fee. @@ -12,17 +14,3 @@ pub struct TxEntry { /// How long the transaction has been in the pool. pub time_in_pool: std::time::Duration, } - -/// Data about a transaction in the pool -/// for use in a block template. -/// -/// Used in [`TxpoolReadResponse::BlockTemplateBacklog`](crate::service::interface::TxpoolReadResponse::BlockTemplateBacklog). -#[derive(Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash)] -pub struct BlockTemplateTxEntry { - /// The transaction's ID (hash). - pub id: [u8; 32], - /// The transaction's weight. - pub weight: u64, - /// The transaction's fee. - pub fee: u64, -}