mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-08 11:17:22 +00:00
Move spawning tasks from thread pools to Service's TaskManager for block importing (#5647)
Co-Authored-By: Pierre Krieger <pierre.krieger1708@gmail.com>
This commit is contained in:
@@ -56,12 +56,13 @@ impl<
|
||||
TExecDisp: 'static + NativeExecutionDispatch,
|
||||
TImpQu: 'static + ImportQueue<TBl>,
|
||||
TRtApi: 'static + Send + Sync,
|
||||
Self: Send + 'static,
|
||||
{
|
||||
type Block = TBl;
|
||||
type NativeDispatch = TExecDisp;
|
||||
|
||||
fn import_blocks(
|
||||
self,
|
||||
mut self,
|
||||
input: impl Read + Seek + Send + 'static,
|
||||
force: bool,
|
||||
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>> {
|
||||
@@ -98,9 +99,6 @@ impl<
|
||||
}
|
||||
}
|
||||
|
||||
let client = self.client;
|
||||
let mut queue = self.import_queue;
|
||||
|
||||
let mut io_reader_input = IoReader(input);
|
||||
let mut count = None::<u64>;
|
||||
let mut read_block_count = 0;
|
||||
@@ -114,6 +112,9 @@ impl<
|
||||
// This makes it possible either to interleave other operations in-between the block imports,
|
||||
// or to stop the operation completely.
|
||||
let import = future::poll_fn(move |cx| {
|
||||
let client = &self.client;
|
||||
let queue = &mut self.import_queue;
|
||||
|
||||
// Start by reading the number of blocks if not done so already.
|
||||
let count = match count {
|
||||
Some(c) => c,
|
||||
@@ -203,13 +204,12 @@ impl<
|
||||
to: Option<NumberFor<TBl>>,
|
||||
binary: bool
|
||||
) -> Pin<Box<dyn Future<Output = Result<(), Error>>>> {
|
||||
let client = self.client;
|
||||
let mut block = from;
|
||||
|
||||
let last = match to {
|
||||
Some(v) if v.is_zero() => One::one(),
|
||||
Some(v) => v,
|
||||
None => client.chain_info().best_number,
|
||||
None => self.client.chain_info().best_number,
|
||||
};
|
||||
|
||||
let mut wrote_header = false;
|
||||
@@ -222,6 +222,8 @@ impl<
|
||||
// This makes it possible either to interleave other operations in-between the block exports,
|
||||
// or to stop the operation completely.
|
||||
let export = future::poll_fn(move |cx| {
|
||||
let client = &self.client;
|
||||
|
||||
if last < block {
|
||||
return std::task::Poll::Ready(Err("Invalid block range specified".into()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user