mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 15:47:58 +00:00
Recover transaction pool on light client (#3833)
* recover tx pool on light client * revert local tests fix * removed import renamings * futures03::Future -> std::future::Future * Update core/transaction-pool/graph/src/error.rs Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * replace remove_from_ready with remove_invalid * avoid excess hashing * debug -> warn * TransactionPool + BasicTransactionPool * pause future tx reject when resubmitting * bump impl_version to make CI happy * and revert back local test fixes * alter doc to restart CI * Transaction::clone() -> Transaction::duplicate() * transactions -> updated_tranasctions * remove explicit consensus-common ref * ::std:: -> std:: * manual set/unset flag -> calling clusore with given flag value * removed comments * removed force argument * BestIterator -> Box<Iterator> * separate crate for TxPool + Maintainer trait * long line fix * pos-merge fix * fix benches compilation * Rename txpoolapi to txpool_api * Clean up. * Finalize merge. * post-merge fix * Move transaction pool api to primitives directly. * Consistent naming for txpool-runtime-api * Warn about missing docs. * Move abstraction for offchain calls to tx-pool-api. * Merge RPC instantiation. * Update cargo.lock * Post merge fixes. * Avoid depending on client. * Fix build
This commit is contained in:
committed by
Gavin Wood
parent
3e26fceda4
commit
a782021ee8
@@ -34,32 +34,68 @@ use std::sync::Arc;
|
||||
use node_primitives::{Block, AccountId, Index, Balance};
|
||||
use node_runtime::UncheckedExtrinsic;
|
||||
use sr_primitives::traits::ProvideRuntimeApi;
|
||||
use transaction_pool::txpool::{ChainApi, Pool};
|
||||
use txpool_api::TransactionPool;
|
||||
|
||||
/// Light client extra dependencies.
|
||||
pub struct LightDeps<F> {
|
||||
/// Remote access to the blockchain (async).
|
||||
pub remote_blockchain: Arc<dyn client::light::blockchain::RemoteBlockchain<Block>>,
|
||||
/// Fetcher instance.
|
||||
pub fetcher: Arc<F>,
|
||||
}
|
||||
|
||||
impl<F> LightDeps<F> {
|
||||
/// Create empty `LightDeps` with given `F` type.
|
||||
///
|
||||
/// This is a convenience method to be used in the service builder,
|
||||
/// to make sure the type of the `LightDeps<F>` is matching.
|
||||
pub fn none(_: Option<Arc<F>>) -> Option<Self> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// Instantiate all RPC extensions.
|
||||
pub fn create<C, P, M>(client: Arc<C>, pool: Arc<Pool<P>>) -> jsonrpc_core::IoHandler<M> where
|
||||
///
|
||||
/// If you provide `LightDeps`, the system is configured for light client.
|
||||
pub fn create<C, P, M, F>(
|
||||
client: Arc<C>,
|
||||
pool: Arc<P>,
|
||||
light_deps: Option<LightDeps<F>>,
|
||||
) -> jsonrpc_core::IoHandler<M> where
|
||||
C: ProvideRuntimeApi,
|
||||
C: client::blockchain::HeaderBackend<Block>,
|
||||
C: Send + Sync + 'static,
|
||||
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>,
|
||||
C::Api: pallet_contracts_rpc::ContractsRuntimeApi<Block, AccountId, Balance>,
|
||||
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance, UncheckedExtrinsic>,
|
||||
P: ChainApi + Sync + Send + 'static,
|
||||
F: client::light::fetcher::Fetcher<Block> + 'static,
|
||||
P: TransactionPool + 'static,
|
||||
M: jsonrpc_core::Metadata + Default,
|
||||
{
|
||||
use substrate_frame_rpc_system::{System, SystemApi};
|
||||
use substrate_frame_rpc_system::{FullSystem, LightSystem, SystemApi};
|
||||
use pallet_contracts_rpc::{Contracts, ContractsApi};
|
||||
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};
|
||||
|
||||
let mut io = jsonrpc_core::IoHandler::default();
|
||||
io.extend_with(
|
||||
SystemApi::to_delegate(System::new(client.clone(), pool))
|
||||
);
|
||||
io.extend_with(
|
||||
ContractsApi::to_delegate(Contracts::new(client.clone()))
|
||||
);
|
||||
io.extend_with(
|
||||
TransactionPaymentApi::to_delegate(TransactionPayment::new(client))
|
||||
);
|
||||
|
||||
if let Some(LightDeps { remote_blockchain, fetcher }) = light_deps {
|
||||
io.extend_with(
|
||||
SystemApi::<AccountId, Index>::to_delegate(LightSystem::new(client, remote_blockchain, fetcher, pool))
|
||||
);
|
||||
} else {
|
||||
io.extend_with(
|
||||
SystemApi::to_delegate(FullSystem::new(client.clone(), pool))
|
||||
);
|
||||
|
||||
// Making synchronous calls in light client freezes the browser currently,
|
||||
// more context: https://github.com/paritytech/substrate/pull/3480
|
||||
// These RPCs should use an asynchronous caller instead.
|
||||
io.extend_with(
|
||||
ContractsApi::to_delegate(Contracts::new(client.clone()))
|
||||
);
|
||||
io.extend_with(
|
||||
TransactionPaymentApi::to_delegate(TransactionPayment::new(client))
|
||||
);
|
||||
}
|
||||
io
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user