mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 15:41:02 +00:00
Cleanup transaction pool deps (#4782)
* Cleanup transaction pool deps * Fix it properly * Fix doc test
This commit is contained in:
@@ -42,8 +42,6 @@ use sp_transaction_pool::{
|
||||
MaintainedTransactionPool, PoolFuture,
|
||||
};
|
||||
|
||||
type PoolResult<T> = PoolFuture<T, error::Error>;
|
||||
|
||||
/// Basic implementation of transaction pool that can be customized by providing PoolApi.
|
||||
pub struct BasicPool<PoolApi, Block>
|
||||
where
|
||||
@@ -80,7 +78,7 @@ impl<PoolApi, Block> BasicPool<PoolApi, Block>
|
||||
/// Create new basic transaction pool with provided api.
|
||||
pub fn new(
|
||||
options: sc_transaction_graph::Options,
|
||||
pool_api: PoolApi,
|
||||
pool_api: Arc<PoolApi>,
|
||||
) -> Self {
|
||||
Self::with_revalidation_type(options, pool_api, RevalidationType::Full)
|
||||
}
|
||||
@@ -89,14 +87,13 @@ impl<PoolApi, Block> BasicPool<PoolApi, Block>
|
||||
/// revalidation type.
|
||||
pub fn with_revalidation_type(
|
||||
options: sc_transaction_graph::Options,
|
||||
pool_api: PoolApi,
|
||||
pool_api: Arc<PoolApi>,
|
||||
revalidation_type: RevalidationType,
|
||||
) -> Self {
|
||||
let api = Arc::new(pool_api);
|
||||
let cloned_api = api.clone();
|
||||
let cloned_api = pool_api.clone();
|
||||
BasicPool {
|
||||
api: cloned_api,
|
||||
pool: Arc::new(sc_transaction_graph::Pool::new(options, api)),
|
||||
pool: Arc::new(sc_transaction_graph::Pool::new(options, pool_api)),
|
||||
revalidation_strategy: Arc::new(Mutex::new(
|
||||
match revalidation_type {
|
||||
RevalidationType::Light => RevalidationStrategy::Light(RevalidationStatus::NotScheduled),
|
||||
@@ -111,29 +108,23 @@ impl<PoolApi, Block> BasicPool<PoolApi, Block>
|
||||
pub fn pool(&self) -> &Arc<sc_transaction_graph::Pool<PoolApi>> {
|
||||
&self.pool
|
||||
}
|
||||
|
||||
/// Get reference to the inner chain api, for tests only.
|
||||
#[cfg(any(feature = "test-helpers", test))]
|
||||
pub fn api(&self) -> &Arc<PoolApi> {
|
||||
&self.api
|
||||
}
|
||||
}
|
||||
|
||||
impl<PoolApi, Block> TransactionPool for BasicPool<PoolApi, Block>
|
||||
where
|
||||
Block: BlockT,
|
||||
PoolApi: 'static + sc_transaction_graph::ChainApi<Block=Block, Hash=Block::Hash, Error=error::Error>,
|
||||
PoolApi: 'static + sc_transaction_graph::ChainApi<Block=Block, Hash=Block::Hash>,
|
||||
{
|
||||
type Block = PoolApi::Block;
|
||||
type Hash = sc_transaction_graph::ExHash<PoolApi>;
|
||||
type InPoolTransaction = sc_transaction_graph::base_pool::Transaction<TxHash<Self>, TransactionFor<Self>>;
|
||||
type Error = error::Error;
|
||||
type Error = PoolApi::Error;
|
||||
|
||||
fn submit_at(
|
||||
&self,
|
||||
at: &BlockId<Self::Block>,
|
||||
xts: Vec<TransactionFor<Self>>,
|
||||
) -> PoolResult<Vec<Result<TxHash<Self>, Self::Error>>> {
|
||||
) -> PoolFuture<Vec<Result<TxHash<Self>, Self::Error>>, Self::Error> {
|
||||
let pool = self.pool.clone();
|
||||
let at = *at;
|
||||
async move {
|
||||
@@ -145,7 +136,7 @@ impl<PoolApi, Block> TransactionPool for BasicPool<PoolApi, Block>
|
||||
&self,
|
||||
at: &BlockId<Self::Block>,
|
||||
xt: TransactionFor<Self>,
|
||||
) -> PoolResult<TxHash<Self>> {
|
||||
) -> PoolFuture<TxHash<Self>, Self::Error> {
|
||||
let pool = self.pool.clone();
|
||||
let at = *at;
|
||||
async move {
|
||||
@@ -157,7 +148,7 @@ impl<PoolApi, Block> TransactionPool for BasicPool<PoolApi, Block>
|
||||
&self,
|
||||
at: &BlockId<Self::Block>,
|
||||
xt: TransactionFor<Self>,
|
||||
) -> PoolResult<Box<TransactionStatusStreamFor<Self>>> {
|
||||
) -> PoolFuture<Box<TransactionStatusStreamFor<Self>>, Self::Error> {
|
||||
let at = *at;
|
||||
let pool = self.pool.clone();
|
||||
|
||||
@@ -287,7 +278,7 @@ impl<N: Clone + Copy + SimpleArithmetic> RevalidationStatus<N> {
|
||||
impl<PoolApi, Block> MaintainedTransactionPool for BasicPool<PoolApi, Block>
|
||||
where
|
||||
Block: BlockT,
|
||||
PoolApi: 'static + sc_transaction_graph::ChainApi<Block=Block, Hash=Block::Hash, Error=error::Error>,
|
||||
PoolApi: 'static + sc_transaction_graph::ChainApi<Block=Block, Hash=Block::Hash>,
|
||||
{
|
||||
fn maintain(&self, id: &BlockId<Self::Block>, retracted: &[BlockHash<Self>])
|
||||
-> Pin<Box<dyn Future<Output=()> + Send>>
|
||||
|
||||
Reference in New Issue
Block a user