txpool: collapse TxEntry

This commit is contained in:
hinto.janai 2024-10-30 18:41:42 -04:00
parent aecbdf5728
commit b30b41a4d8
No known key found for this signature in database
GPG key ID: D47CE05FA175A499
3 changed files with 3 additions and 33 deletions

View file

@ -9,7 +9,7 @@ use std::{
use cuprate_types::TransactionVerificationData; use cuprate_types::TransactionVerificationData;
use crate::{ use crate::{
tx::{BlockTemplateTxEntry, TxEntry}, tx::TxEntry,
types::{KeyImage, TransactionBlobHash, TransactionHash}, types::{KeyImage, TransactionBlobHash, TransactionHash},
}; };
@ -34,12 +34,6 @@ pub enum TxpoolReadRequest {
/// Get information on all transactions in the pool. /// Get information on all transactions in the pool.
Backlog, 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. /// Get the number of transactions in the pool.
Size { Size {
/// If this is [`true`], the size returned will /// If this is [`true`], the size returned will
@ -80,11 +74,6 @@ pub enum TxpoolReadResponse {
/// the transactions currently in the pool. /// the transactions currently in the pool.
Backlog(Vec<TxEntry>), Backlog(Vec<TxEntry>),
/// Response to [`TxpoolReadRequest::BlockTemplateBacklog`].
///
/// The inner [`Vec`] contains information on transactions
BlockTemplateBacklog(Vec<BlockTemplateTxEntry>),
/// Response to [`TxpoolReadRequest::Size`]. /// Response to [`TxpoolReadRequest::Size`].
/// ///
/// The inner value is the amount of /// The inner value is the amount of

View file

@ -71,7 +71,6 @@ fn map_request(
} }
TxpoolReadRequest::TxsForBlock(txs_needed) => txs_for_block(env, txs_needed), TxpoolReadRequest::TxsForBlock(txs_needed) => txs_for_block(env, txs_needed),
TxpoolReadRequest::Backlog => backlog(env), TxpoolReadRequest::Backlog => backlog(env),
TxpoolReadRequest::BlockTemplateBacklog => block_template_backlog(env),
TxpoolReadRequest::Size { TxpoolReadRequest::Size {
include_sensitive_txs, include_sensitive_txs,
} => size(env, include_sensitive_txs), } => size(env, include_sensitive_txs),
@ -202,12 +201,6 @@ fn backlog(env: &ConcreteEnv) -> ReadResponseResult {
Ok(TxpoolReadResponse::Backlog(todo!())) Ok(TxpoolReadResponse::Backlog(todo!()))
} }
/// [`TxpoolReadRequest::BlockTemplateBacklog`].
#[inline]
fn block_template_backlog(env: &ConcreteEnv) -> ReadResponseResult {
Ok(TxpoolReadResponse::BlockTemplateBacklog(todo!()))
}
/// [`TxpoolReadRequest::Size`]. /// [`TxpoolReadRequest::Size`].
#[inline] #[inline]
fn size(env: &ConcreteEnv, include_sensitive_txs: bool) -> ReadResponseResult { fn size(env: &ConcreteEnv, include_sensitive_txs: bool) -> ReadResponseResult {

View file

@ -5,6 +5,8 @@
/// Used in [`TxpoolReadResponse::Backlog`](crate::service::interface::TxpoolReadResponse::Backlog). /// Used in [`TxpoolReadResponse::Backlog`](crate::service::interface::TxpoolReadResponse::Backlog).
#[derive(Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash)] #[derive(Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash)]
pub struct TxEntry { pub struct TxEntry {
/// The transaction's ID (hash).
pub id: [u8; 32],
/// The transaction's weight. /// The transaction's weight.
pub weight: u64, pub weight: u64,
/// The transaction's fee. /// The transaction's fee.
@ -12,17 +14,3 @@ pub struct TxEntry {
/// How long the transaction has been in the pool. /// How long the transaction has been in the pool.
pub time_in_pool: std::time::Duration, 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,
}