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

Fix light sync deadlock (blocks import queue) #260

Merged
merged 5 commits into from
Jul 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions substrate/network/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use runtime_primitives::bft::Justification;
/// Local client abstraction for the network.
pub trait Client<Block: BlockT>: Send + Sync {
/// Import a new block. Parent is supposed to be existing in the blockchain.
fn import(&self, is_best: bool, header: Block::Header, justification: Justification<Block::Hash>, body: Option<Vec<Block::Extrinsic>>) -> Result<ImportResult, Error>;
fn import(&self, origin: BlockOrigin, header: Block::Header, justification: Justification<Block::Hash>, body: Option<Vec<Block::Extrinsic>>) -> Result<ImportResult, Error>;

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

Expand Down
2 changes: 2 additions & 0 deletions substrate/network/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@

//! Polkadot service possible errors.

use std::io::Error as IoError;
use network_libp2p::Error as NetworkError;
use client;

error_chain! {
foreign_links {
Network(NetworkError) #[doc = "Devp2p error."];
Io(IoError) #[doc = "IO error."];
}

links {
Expand Down
Loading