Refactor tx-pool maintenance and other high-level api (#4629)

* Reduction.

* Reformation.

* add locked timer stuff

* fix issues and introduce full pool

* arrange together

* fix benches

* fix new_light

* Add revalidation test case

* review fixes

* review fixes

* use just ready future

* address review
This commit is contained in:
Nikolay Volf
2020-01-24 04:21:24 -08:00
committed by GitHub
parent b89ac5d2ef
commit 14e95f3398
12 changed files with 423 additions and 827 deletions
+8 -16
View File
@@ -64,9 +64,7 @@ macro_rules! new_full_start {
.with_transaction_pool(|config, client, _fetcher| {
let pool_api = sc_transaction_pool::FullChainApi::new(client.clone());
let pool = sc_transaction_pool::BasicPool::new(config, pool_api);
let maintainer = sc_transaction_pool::FullBasicPoolMaintainer::new(pool.pool().clone(), client);
let maintainable_pool = sp_transaction_pool::MaintainableTransactionPool::new(pool, maintainer);
Ok(maintainable_pool)
Ok(pool)
})?
.with_import_queue(|_config, client, mut select_chain, _transaction_pool| {
let select_chain = select_chain.take()
@@ -272,15 +270,9 @@ type ConcreteClient =
#[allow(dead_code)]
type ConcreteBackend = Backend<ConcreteBlock>;
#[allow(dead_code)]
type ConcreteTransactionPool = sp_transaction_pool::MaintainableTransactionPool<
sc_transaction_pool::BasicPool<
sc_transaction_pool::FullChainApi<ConcreteClient, ConcreteBlock>,
ConcreteBlock
>,
sc_transaction_pool::FullBasicPoolMaintainer<
ConcreteClient,
sc_transaction_pool::FullChainApi<ConcreteClient, Block>
>
type ConcreteTransactionPool = sc_transaction_pool::BasicPool<
sc_transaction_pool::FullChainApi<ConcreteClient, ConcreteBlock>,
ConcreteBlock
>;
/// A specialized configuration object for setting up the node..
@@ -322,10 +314,10 @@ pub fn new_light<C: Send + Default + 'static>(config: NodeConfiguration<C>)
let fetcher = fetcher
.ok_or_else(|| "Trying to start light transaction pool without active fetcher")?;
let pool_api = sc_transaction_pool::LightChainApi::new(client.clone(), fetcher.clone());
let pool = sc_transaction_pool::BasicPool::new(config, pool_api);
let maintainer = sc_transaction_pool::LightBasicPoolMaintainer::with_defaults(pool.pool().clone(), client, fetcher);
let maintainable_pool = sp_transaction_pool::MaintainableTransactionPool::new(pool, maintainer);
Ok(maintainable_pool)
let pool = sc_transaction_pool::BasicPool::with_revalidation_type(
config, pool_api, sc_transaction_pool::RevalidationType::Light,
);
Ok(pool)
})?
.with_import_queue_and_fprb(|_config, client, backend, fetcher, _select_chain, _tx_pool| {
let fetch_checker = fetcher