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

Commit

Permalink
Fix light sync deadlock (blocks import queue) (#260)
Browse files Browse the repository at this point in the history
* fix light sync deadlock

* some more docs
  • Loading branch information
svyatonik authored and arkpar committed Jul 16, 2018
1 parent a996430 commit 15e3df7
Show file tree
Hide file tree
Showing 9 changed files with 637 additions and 91 deletions.
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

0 comments on commit 15e3df7

Please sign in to comment.