feat: add futures api to TransactionPool (#1348)

* feat: add futures api to `TransactionPool`

* fix clippy
This commit is contained in:
yjh
2023-09-04 03:52:20 +08:00
committed by GitHub
parent bc6fca3c44
commit 4053bdac03
5 changed files with 15 additions and 3 deletions
@@ -282,6 +282,10 @@ impl sc_transaction_pool_api::TransactionPool for Transactions {
Default::default()
}
fn futures(&self) -> Vec<Self::InPoolTransaction> {
unimplemented!()
}
fn status(&self) -> PoolStatus {
unimplemented!()
}
@@ -247,6 +247,9 @@ pub trait TransactionPool: Send + Sync {
fn remove_invalid(&self, hashes: &[TxHash<Self>]) -> Vec<Arc<Self::InPoolTransaction>>;
// *** logging
/// Get futures transaction list.
fn futures(&self) -> Vec<Self::InPoolTransaction>;
/// Returns pool status.
fn status(&self) -> PoolStatus;
@@ -84,8 +84,7 @@ pub struct PruneStatus<Hash, Ex> {
}
/// Immutable transaction
#[cfg_attr(test, derive(Clone))]
#[derive(PartialEq, Eq)]
#[derive(PartialEq, Eq, Clone)]
pub struct Transaction<Hash, Extrinsic> {
/// Raw extrinsic representing that transaction.
pub data: Extrinsic,
@@ -106,7 +106,7 @@ pub struct ValidatedPool<B: ChainApi> {
is_validator: IsValidator,
options: Options,
listener: RwLock<Listener<ExtrinsicHash<B>, B>>,
pool: RwLock<base::BasePool<ExtrinsicHash<B>, ExtrinsicFor<B>>>,
pub(crate) pool: RwLock<base::BasePool<ExtrinsicHash<B>, ExtrinsicFor<B>>>,
import_notification_sinks: Mutex<Vec<Sender<ExtrinsicHash<B>>>>,
rotator: PoolRotator<ExtrinsicHash<B>>,
}
@@ -358,6 +358,12 @@ where
fn ready(&self) -> ReadyIteratorFor<PoolApi> {
Box::new(self.pool.validated_pool().ready())
}
fn futures(&self) -> Vec<Self::InPoolTransaction> {
let pool = self.pool.validated_pool().pool.read();
pool.futures().cloned().collect::<Vec<_>>()
}
}
impl<Block, Client> FullPool<Block, Client>