Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 15e3df7

Browse files
svyatonikarkpar
authored andcommitted
Fix light sync deadlock (blocks import queue) (#260)
* fix light sync deadlock * some more docs
1 parent a996430 commit 15e3df7

File tree

9 files changed

+637
-91
lines changed

9 files changed

+637
-91
lines changed

substrate/network/src/chain.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use runtime_primitives::bft::Justification;
2525
/// Local client abstraction for the network.
2626
pub trait Client<Block: BlockT>: Send + Sync {
2727
/// Import a new block. Parent is supposed to be existing in the blockchain.
28-
fn import(&self, is_best: bool, header: Block::Header, justification: Justification<Block::Hash>, body: Option<Vec<Block::Extrinsic>>) -> Result<ImportResult, Error>;
28+
fn import(&self, origin: BlockOrigin, header: Block::Header, justification: Justification<Block::Hash>, body: Option<Vec<Block::Extrinsic>>) -> Result<ImportResult, Error>;
2929

3030
/// Get blockchain info.
3131
fn info(&self) -> Result<ClientInfo<Block>, Error>;
@@ -54,10 +54,9 @@ impl<B, E, Block> Client<Block> for SubstrateClient<B, E, Block> where
5454
E: CallExecutor<Block> + Send + Sync + 'static,
5555
Block: BlockT,
5656
{
57-
fn import(&self, is_best: bool, header: Block::Header, justification: Justification<Block::Hash>, body: Option<Vec<Block::Extrinsic>>) -> Result<ImportResult, Error> {
57+
fn import(&self, origin: BlockOrigin, header: Block::Header, justification: Justification<Block::Hash>, body: Option<Vec<Block::Extrinsic>>) -> Result<ImportResult, Error> {
5858
// TODO: defer justification check.
5959
let justified_header = self.check_justification(header, justification.into())?;
60-
let origin = if is_best { BlockOrigin::NetworkBroadcast } else { BlockOrigin::NetworkInitialSync };
6160
(self as &SubstrateClient<B, E, Block>).import_block(origin, justified_header, body)
6261
}
6362

substrate/network/src/error.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@
1616

1717
//! Polkadot service possible errors.
1818
19+
use std::io::Error as IoError;
1920
use network_libp2p::Error as NetworkError;
2021
use client;
2122

2223
error_chain! {
2324
foreign_links {
2425
Network(NetworkError) #[doc = "Devp2p error."];
26+
Io(IoError) #[doc = "IO error."];
2527
}
2628

2729
links {

0 commit comments

Comments
 (0)