where
C: ProvideRuntimeApi + Send + Sync + client_api::backend::AuxStore + ProvideCache + BlockOf,
- C::Api: BlockBuilderApi + AuraApi> + ApiExt,
+ C::Api: BlockBuilderApi + AuraApi> + ApiExt,
DigestItemFor: CompatibleDigestItem,
P: Pair + Send + Sync + 'static,
P::Public: Send + Sync + Hash + Eq + Clone + Decode + Encode + Debug + 'static,
@@ -682,7 +685,7 @@ pub fn import_queue(
) -> Result, consensus_common::Error> where
B: BlockT,
C: 'static + ProvideRuntimeApi + BlockOf + ProvideCache + Send + Sync + AuxStore,
- C::Api: BlockBuilderApi + AuraApi> + ApiExt,
+ C::Api: BlockBuilderApi + AuraApi> + ApiExt,
DigestItemFor: CompatibleDigestItem,
P: Pair + Send + Sync + 'static,
P::Public: Clone + Eq + Send + Sync + Hash + Debug + Encode + Decode,
@@ -721,7 +724,7 @@ mod tests {
use test_client;
use aura_primitives::sr25519::AuthorityPair;
- type Error = client::error::Error;
+ type Error = sp_blockchain::Error;
type TestClient = client::Client<
test_client::Backend,
diff --git a/substrate/client/consensus/babe/Cargo.toml b/substrate/client/consensus/babe/Cargo.toml
index 2baf4835d8..a9dd0c5890 100644
--- a/substrate/client/consensus/babe/Cargo.toml
+++ b/substrate/client/consensus/babe/Cargo.toml
@@ -23,7 +23,7 @@ client-api = { package = "substrate-client-api", path = "../../api" }
client = { package = "substrate-client", path = "../../" }
sr-api = { path = "../../../primitives/sr-api" }
block-builder-api = { package = "substrate-block-builder-runtime-api", path = "../../../primitives/block-builder/runtime-api" }
-header-metadata = { package = "substrate-header-metadata", path = "../../header-metadata" }
+sp-blockchain = { path = "../../../primitives/blockchain" }
consensus-common = { package = "substrate-consensus-common", path = "../../../primitives/consensus/common" }
uncles = { package = "substrate-consensus-uncles", path = "../uncles" }
slots = { package = "substrate-consensus-slots", path = "../slots" }
diff --git a/substrate/client/consensus/babe/src/aux_schema.rs b/substrate/client/consensus/babe/src/aux_schema.rs
index 04e9f81e5c..288f20db97 100644
--- a/substrate/client/consensus/babe/src/aux_schema.rs
+++ b/substrate/client/consensus/babe/src/aux_schema.rs
@@ -19,10 +19,8 @@
use log::info;
use codec::{Decode, Encode};
-use client_api::{
- backend::AuxStore,
- error::{Result as ClientResult, Error as ClientError},
-};
+use client_api::backend::AuxStore;
+use sp_blockchain::{Result as ClientResult, Error as ClientError};
use sr_primitives::traits::Block as BlockT;
use babe_primitives::BabeBlockWeight;
diff --git a/substrate/client/consensus/babe/src/epoch_changes.rs b/substrate/client/consensus/babe/src/epoch_changes.rs
index a5621efcd1..a07235c4ff 100644
--- a/substrate/client/consensus/babe/src/epoch_changes.rs
+++ b/substrate/client/consensus/babe/src/epoch_changes.rs
@@ -25,12 +25,8 @@ use fork_tree::ForkTree;
use parking_lot::{Mutex, MutexGuard};
use sr_primitives::traits::{Block as BlockT, NumberFor, One, Zero};
use codec::{Encode, Decode};
-use client_api::{
- error::Error as ClientError,
- utils::is_descendent_of,
- blockchain::HeaderBackend
-};
-use header_metadata::HeaderMetadata;
+use client_api::utils::is_descendent_of;
+use sp_blockchain::{HeaderMetadata, HeaderBackend, Error as ClientError};
use primitives::H256;
use std::ops::Add;
diff --git a/substrate/client/consensus/babe/src/lib.rs b/substrate/client/consensus/babe/src/lib.rs
index 5d327bcedf..3fd1e526d4 100644
--- a/substrate/client/consensus/babe/src/lib.rs
+++ b/substrate/client/consensus/babe/src/lib.rs
@@ -90,8 +90,6 @@ use consensus_common::import_queue::{Verifier, BasicQueue, CacheKeyId};
use client_api::{
backend::{AuxStore, Backend},
call_executor::CallExecutor,
- error::{Result as ClientResult, Error as ClientError},
- blockchain::{self, HeaderBackend, ProvideCache},
BlockchainEvents, ProvideUncles,
};
use client::Client;
@@ -103,7 +101,10 @@ use futures::prelude::*;
use log::{warn, debug, info, trace};
use slots::{SlotWorker, SlotData, SlotInfo, SlotCompatible};
use epoch_changes::descendent_query;
-use header_metadata::HeaderMetadata;
+use sp_blockchain::{
+ Result as ClientResult, Error as ClientError,
+ HeaderBackend, ProvideCache, HeaderMetadata
+};
use schnorrkel::SignatureError;
use sr_api::ApiExt;
@@ -157,11 +158,11 @@ enum Error {
#[display(fmt = "VRF verification failed: {:?}", _0)]
VRFVerificationFailed(SignatureError),
#[display(fmt = "Could not fetch parent header: {:?}", _0)]
- FetchParentHeader(client_api::error::Error),
+ FetchParentHeader(sp_blockchain::Error),
#[display(fmt = "Expected epoch change to happen at {:?}, s{}", _0, _1)]
ExpectedEpochChange(B::Hash, u64),
#[display(fmt = "Could not look up epoch: {:?}", _0)]
- CouldNotLookUpEpoch(Box>),
+ CouldNotLookUpEpoch(Box>),
#[display(fmt = "Block {} is not valid under any epoch.", _0)]
BlockNotValid(B::Hash),
#[display(fmt = "Unexpected epoch change")]
@@ -170,9 +171,9 @@ enum Error {
ParentBlockNoAssociatedWeight(B::Hash),
#[display(fmt = "Checking inherents failed: {}", _0)]
CheckInherents(String),
- Client(client_api::error::Error),
+ Client(sp_blockchain::Error),
Runtime(inherents::Error),
- ForkTree(Box>),
+ ForkTree(Box>),
}
impl std::convert::From> for String {
@@ -206,7 +207,7 @@ impl Config {
/// Either fetch the slot duration from disk or compute it from the genesis
/// state.
pub fn get_or_compute(client: &C) -> ClientResult where
- C: AuxStore + ProvideRuntimeApi, C::Api: BabeApi,
+ C: AuxStore + ProvideRuntimeApi, C::Api: BabeApi,
{
trace!(target: "babe", "Getting slot duration");
match slots::SlotDuration::get_or_compute(client, |a, b| a.configuration(b)).map(Self) {
@@ -558,7 +559,7 @@ impl BabeVerifier {
block_id: BlockId,
inherent_data: InherentData,
) -> Result<(), Error>
- where PRA: ProvideRuntimeApi, PRA::Api: BlockBuilderApi
+ where PRA: ProvideRuntimeApi, PRA::Api: BlockBuilderApi
{
let inherent_res = self.api.runtime_api().check_inherents(
&block_id,
@@ -627,8 +628,8 @@ impl Verifier for BabeVerifier + 'static + Clone + Send + Sync,
RA: Send + Sync,
PRA: ProvideRuntimeApi + Send + Sync + AuxStore + ProvideCache,
- PRA::Api: BlockBuilderApi
- + BabeApi,
+ PRA::Api: BlockBuilderApi
+ + BabeApi,
{
fn verify(
&mut self,
@@ -851,8 +852,8 @@ impl BlockImport for BabeBlockImport return Ok(ImportResult::AlreadyInChain),
- Ok(blockchain::BlockStatus::Unknown) => {},
+ Ok(sp_blockchain::BlockStatus::InChain) => return Ok(ImportResult::AlreadyInChain),
+ Ok(sp_blockchain::BlockStatus::Unknown) => {},
Err(e) => return Err(ConsensusError::ClientImport(e.to_string())),
}
@@ -907,7 +908,7 @@ impl BlockImport for BabeBlockImport| ConsensusError::ChainLookup(
+ .map_err(|e: fork_tree::Error| ConsensusError::ChainLookup(
babe_err(Error::::CouldNotLookUpEpoch(Box::new(e))).into()
))?
.ok_or_else(|| ConsensusError::ClientImport(
@@ -1146,7 +1147,7 @@ pub fn import_queue, I, RA, PRA>(
E: CallExecutor + Clone + Send + Sync + 'static,
RA: Send + Sync + 'static,
PRA: ProvideRuntimeApi + ProvideCache + Send + Sync + AuxStore + 'static,
- PRA::Api: BlockBuilderApi + BabeApi + ApiExt,
+ PRA::Api: BlockBuilderApi + BabeApi + ApiExt,
{
register_babe_inherent_data_provider(&inherent_data_providers, babe_link.config.slot_duration)?;
diff --git a/substrate/client/consensus/babe/src/tests.rs b/substrate/client/consensus/babe/src/tests.rs
index 19c5844511..4695eb721f 100644
--- a/substrate/client/consensus/babe/src/tests.rs
+++ b/substrate/client/consensus/babe/src/tests.rs
@@ -41,7 +41,7 @@ use std::{time::Duration, cell::RefCell};
type Item = DigestItem;
-type Error = client::error::Error;
+type Error = sp_blockchain::Error;
type TestClient = client::Client<
test_client::Backend,
diff --git a/substrate/client/consensus/pow/Cargo.toml b/substrate/client/consensus/pow/Cargo.toml
index 8ed1af9923..acdfb9e843 100644
--- a/substrate/client/consensus/pow/Cargo.toml
+++ b/substrate/client/consensus/pow/Cargo.toml
@@ -8,6 +8,7 @@ edition = "2018"
[dependencies]
codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] }
primitives = { package = "substrate-primitives", path = "../../../primitives/core" }
+sp-blockchain = { path = "../../../primitives/blockchain" }
sr-primitives = { path = "../../../primitives/sr-primitives" }
client-api = { package = "substrate-client-api", path = "../../api" }
block-builder-api = { package = "substrate-block-builder-runtime-api", path = "../../../primitives/block-builder/runtime-api" }
diff --git a/substrate/client/consensus/pow/src/lib.rs b/substrate/client/consensus/pow/src/lib.rs
index cb3f23fbf5..1daa9c4eae 100644
--- a/substrate/client/consensus/pow/src/lib.rs
+++ b/substrate/client/consensus/pow/src/lib.rs
@@ -32,10 +32,8 @@
use std::sync::Arc;
use std::thread;
use std::collections::HashMap;
-use client_api::{
- BlockOf, blockchain::{HeaderBackend, ProvideCache}, backend::AuxStore,
- well_known_cache_keys::Id as CacheKeyId,
-};
+use client_api::{BlockOf, backend::AuxStore};
+use sp_blockchain::{HeaderBackend, ProvideCache, well_known_cache_keys::Id as CacheKeyId};
use block_builder_api::BlockBuilder as BlockBuilderApi;
use sr_primitives::{Justification, RuntimeString};
use sr_primitives::generic::{BlockId, Digest, DigestItem};
@@ -66,7 +64,7 @@ pub enum Error {
#[display(fmt = "Fetching best header failed using select chain: {:?}", _0)]
BestHeaderSelectChain(ConsensusError),
#[display(fmt = "Fetching best header failed: {:?}", _0)]
- BestHeader(client_api::error::Error),
+ BestHeader(sp_blockchain::Error),
#[display(fmt = "Best header does not exist")]
NoBestHeader,
#[display(fmt = "Block proposing error: {:?}", _0)]
@@ -79,7 +77,7 @@ pub enum Error {
CreateInherents(inherents::Error),
#[display(fmt = "Checking inherents failed: {}", _0)]
CheckInherents(String),
- Client(client_api::error::Error),
+ Client(sp_blockchain::Error),
Codec(codec::Error),
Environment(String),
Runtime(RuntimeString)
@@ -211,7 +209,7 @@ impl, C, S, Algorithm> PowVerifier {
inherent_data: InherentData,
timestamp_now: u64,
) -> Result<(), Error> where
- C: ProvideRuntimeApi, C::Api: BlockBuilderApi
+ C: ProvideRuntimeApi, C::Api: BlockBuilderApi
{
const MAX_TIMESTAMP_DRIFT_SECS: u64 = 60;
@@ -249,7 +247,7 @@ impl, C, S, Algorithm> PowVerifier