Skip to content

Commit d40c3bb

Browse files
kien-riselwedge99
authored andcommitted
refactor: change PendingPool and PendingTransaction visibility to pub (paradigmxyz#18267)
1 parent e365920 commit d40c3bb

File tree

4 files changed

+31
-13
lines changed

4 files changed

+31
-13
lines changed

crates/transaction-pool/src/pool/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ mod best;
113113
mod blob;
114114
mod listener;
115115
mod parked;
116-
pub(crate) mod pending;
116+
pub mod pending;
117117
pub(crate) mod size;
118118
pub(crate) mod state;
119119
pub mod txpool;

crates/transaction-pool/src/pool/pending.rs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Pending transactions
2+
13
use crate::{
24
identifier::{SenderId, TransactionId},
35
pool::{
@@ -511,6 +513,21 @@ impl<T: TransactionOrdering> PendingPool<T> {
511513
self.by_id.len()
512514
}
513515

516+
/// All transactions grouped by id
517+
pub const fn by_id(&self) -> &BTreeMap<TransactionId, PendingTransaction<T>> {
518+
&self.by_id
519+
}
520+
521+
/// Independent transactions
522+
pub const fn independent_transactions(&self) -> &FxHashMap<SenderId, PendingTransaction<T>> {
523+
&self.independent_transactions
524+
}
525+
526+
/// Subscribes to new transactions
527+
pub fn new_transaction_receiver(&self) -> broadcast::Receiver<PendingTransaction<T>> {
528+
self.new_transaction_notifier.subscribe()
529+
}
530+
514531
/// Whether the pool is empty
515532
#[cfg(test)]
516533
pub(crate) fn is_empty(&self) -> bool {
@@ -570,18 +587,18 @@ impl<T: TransactionOrdering> PendingPool<T> {
570587

571588
/// A transaction that is ready to be included in a block.
572589
#[derive(Debug)]
573-
pub(crate) struct PendingTransaction<T: TransactionOrdering> {
590+
pub struct PendingTransaction<T: TransactionOrdering> {
574591
/// Identifier that tags when transaction was submitted in the pool.
575-
pub(crate) submission_id: u64,
592+
pub submission_id: u64,
576593
/// Actual transaction.
577-
pub(crate) transaction: Arc<ValidPoolTransaction<T::Transaction>>,
594+
pub transaction: Arc<ValidPoolTransaction<T::Transaction>>,
578595
/// The priority value assigned by the used `Ordering` function.
579-
pub(crate) priority: Priority<T::PriorityValue>,
596+
pub priority: Priority<T::PriorityValue>,
580597
}
581598

582599
impl<T: TransactionOrdering> PendingTransaction<T> {
583600
/// The next transaction of the sender: `nonce + 1`
584-
pub(crate) fn unlocks(&self) -> TransactionId {
601+
pub fn unlocks(&self) -> TransactionId {
585602
self.transaction.transaction_id.descendant()
586603
}
587604
}

crates/transaction-pool/src/pool/txpool.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,18 +1210,19 @@ impl<T: TransactionOrdering> Drop for TxPool<T> {
12101210
}
12111211
}
12121212

1213-
// Additional test impls
1214-
#[cfg(any(test, feature = "test-utils"))]
12151213
impl<T: TransactionOrdering> TxPool<T> {
1216-
pub(crate) const fn pending(&self) -> &PendingPool<T> {
1214+
/// Pending subpool
1215+
pub const fn pending(&self) -> &PendingPool<T> {
12171216
&self.pending_pool
12181217
}
12191218

1220-
pub(crate) const fn base_fee(&self) -> &ParkedPool<BasefeeOrd<T::Transaction>> {
1219+
/// Base fee subpool
1220+
pub const fn base_fee(&self) -> &ParkedPool<BasefeeOrd<T::Transaction>> {
12211221
&self.basefee_pool
12221222
}
12231223

1224-
pub(crate) const fn queued(&self) -> &ParkedPool<QueuedOrd<T::Transaction>> {
1224+
/// Queued sub pool
1225+
pub const fn queued(&self) -> &ParkedPool<QueuedOrd<T::Transaction>> {
12251226
&self.queued_pool
12261227
}
12271228
}

crates/transaction-pool/src/validate/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,12 +335,12 @@ impl<T: PoolTransaction> ValidPoolTransaction<T> {
335335
}
336336

337337
/// Returns the internal identifier for the sender of this transaction
338-
pub(crate) const fn sender_id(&self) -> SenderId {
338+
pub const fn sender_id(&self) -> SenderId {
339339
self.transaction_id.sender
340340
}
341341

342342
/// Returns the internal identifier for this transaction.
343-
pub(crate) const fn id(&self) -> &TransactionId {
343+
pub const fn id(&self) -> &TransactionId {
344344
&self.transaction_id
345345
}
346346

0 commit comments

Comments
 (0)