Skip to content

Commit 9263aff

Browse files
Aleksandar Brayanovtmpolaczyk
authored andcommitted
feat: added as_any implementation to FullClientTransactionPool
1 parent 57dacf8 commit 9263aff

2 files changed

Lines changed: 21 additions & 15 deletions

File tree

substrate/client/transaction-pool/src/builder.rs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,19 +110,19 @@ impl TransactionPoolOptions {
110110
/// This trait defines the requirements for a full client transaction pool, ensuring
111111
/// that it can handle transactions submission and maintenance.
112112
pub trait FullClientTransactionPool<Block, Client>:
113-
MaintainedTransactionPool<
114-
Block = Block,
115-
Hash = ExtrinsicHash<FullChainApi<Client, Block>>,
116-
InPoolTransaction = Transaction<
117-
ExtrinsicHash<FullChainApi<Client, Block>>,
118-
ExtrinsicFor<FullChainApi<Client, Block>>,
119-
>,
120-
Error = <FullChainApi<Client, Block> as ChainApi>::Error,
121-
> + LocalTransactionPool<
122-
Block = Block,
123-
Hash = ExtrinsicHash<FullChainApi<Client, Block>>,
124-
Error = <FullChainApi<Client, Block> as ChainApi>::Error,
125-
>
113+
MaintainedTransactionPool<
114+
Block = Block,
115+
Hash = ExtrinsicHash<FullChainApi<Client, Block>>,
116+
InPoolTransaction=Transaction<
117+
ExtrinsicHash<FullChainApi<Client, Block>>,
118+
ExtrinsicFor<FullChainApi<Client, Block>>,
119+
>,
120+
Error = <FullChainApi<Client, Block> as ChainApi>::Error,
121+
> + LocalTransactionPool<
122+
Block = Block,
123+
Hash = ExtrinsicHash<FullChainApi<Client, Block>>,
124+
Error = <FullChainApi<Client, Block> as ChainApi>::Error,
125+
> + std::any::Any
126126
where
127127
Block: BlockT,
128128
Client: sp_api::ProvideRuntimeApi<Block>
@@ -133,6 +133,9 @@ where
133133
+ 'static,
134134
Client::Api: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>,
135135
{
136+
/// Return the inner pool as a `&dyn Any`, can be used to downcast to the concrete pool
137+
/// type and use methods that only exist in that pool implementation.
138+
fn as_any(&self) -> &dyn std::any::Any;
136139
}
137140

138141
impl<Block, Client, P> FullClientTransactionPool<Block, Client> for P
@@ -157,8 +160,11 @@ where
157160
Block = Block,
158161
Hash = ExtrinsicHash<FullChainApi<Client, Block>>,
159162
Error = <FullChainApi<Client, Block> as ChainApi>::Error,
160-
>,
163+
>+ 'static,
161164
{
165+
fn as_any(&self) -> &dyn std::any::Any {
166+
self as &dyn std::any::Any
167+
}
162168
}
163169

164170
/// The public type alias for the actual type providing the implementation of

substrate/client/transaction-pool/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use common::{api, enactment_state};
3333
use std::{future::Future, pin::Pin, sync::Arc};
3434

3535
pub use api::FullChainApi;
36-
pub use builder::{Builder, TransactionPoolHandle, TransactionPoolOptions, TransactionPoolType};
36+
pub use builder::{Builder, TransactionPoolHandle, TransactionPoolOptions, TransactionPoolType, FullClientTransactionPool};
3737
pub use common::notification_future;
3838
pub use fork_aware_txpool::{ForkAwareTxPool, ForkAwareTxPoolTask};
3939
pub use graph::{base_pool::Limit as PoolLimit, ChainApi, Options, Pool};

0 commit comments

Comments
 (0)