ImportBlock -> BlockImportParams (#3158)

This commit is contained in:
Pierre Krieger
2019-07-22 00:43:02 +02:00
committed by DemiMarie-parity
parent 4bbfaa9c8f
commit 2edeef5825
16 changed files with 53 additions and 53 deletions
+4 -4
View File
@@ -32,7 +32,7 @@ use std::{sync::Arc, time::Duration, thread, marker::PhantomData, hash::Hash, fm
use parity_codec::{Encode, Decode, Codec};
use consensus_common::{self, BlockImport, Environment, Proposer,
ForkChoiceStrategy, ImportBlock, BlockOrigin, Error as ConsensusError,
ForkChoiceStrategy, BlockImportParams, BlockOrigin, Error as ConsensusError,
SelectChain, well_known_cache_keys::{self, Id as CacheKeyId}
};
use consensus_common::import_queue::{
@@ -317,7 +317,7 @@ impl<H, B, C, E, I, P, Error, SO> SlotWorker<B> for AuraWorker<C, E, I, P, SO> w
let signature = pair.sign(header_hash.as_ref());
let signature_digest_item = <DigestItemFor<B> as CompatibleDigestItem<P>>::aura_seal(signature);
let import_block: ImportBlock<B> = ImportBlock {
let import_block: BlockImportParams<B> = BlockImportParams {
origin: BlockOrigin::Own,
header,
justification: None,
@@ -515,7 +515,7 @@ impl<B: BlockT, C, P> Verifier<B> for AuraVerifier<C, P> where
header: B::Header,
justification: Option<Justification>,
mut body: Option<Vec<B::Extrinsic>>,
) -> Result<(ImportBlock<B>, Option<Vec<(CacheKeyId, Vec<u8>)>>), String> {
) -> Result<(BlockImportParams<B>, Option<Vec<(CacheKeyId, Vec<u8>)>>), String> {
let mut inherent_data = self.inherent_data_providers.create_inherent_data().map_err(String::from)?;
let (timestamp_now, slot_now, _) = AuraSlotCompatible.extract_timestamp_and_slot(&inherent_data)
.map_err(|e| format!("Could not extract timestamp and slot: {:?}", e))?;
@@ -578,7 +578,7 @@ impl<B: BlockT, C, P> Verifier<B> for AuraVerifier<C, P> where
_ => None,
});
let import_block = ImportBlock {
let import_block = BlockImportParams {
origin,
header: pre_header,
post_digests: vec![seal],
+4 -4
View File
@@ -62,7 +62,7 @@ use schnorrkel::{
};
use consensus_common::{
self, BlockImport, Environment, Proposer,
ForkChoiceStrategy, ImportBlock, BlockOrigin, Error as ConsensusError,
ForkChoiceStrategy, BlockImportParams, BlockOrigin, Error as ConsensusError,
};
use srml_babe::{
BabeInherentData,
@@ -373,7 +373,7 @@ impl<Hash, H, B, C, E, I, Error, SO> SlotWorker<B> for BabeWorker<C, E, I, SO> w
let signature = pair.sign(header_hash.as_ref());
let signature_digest_item = DigestItemFor::<B>::babe_seal(signature);
let import_block: ImportBlock<B> = ImportBlock {
let import_block: BlockImportParams<B> = BlockImportParams {
origin: BlockOrigin::Own,
header,
justification: None,
@@ -598,7 +598,7 @@ impl<B: BlockT, C> Verifier<B> for BabeVerifier<C> where
header: B::Header,
justification: Option<Justification>,
mut body: Option<Vec<B::Extrinsic>>,
) -> Result<(ImportBlock<B>, Option<Vec<(CacheKeyId, Vec<u8>)>>), String> {
) -> Result<(BlockImportParams<B>, Option<Vec<(CacheKeyId, Vec<u8>)>>), String> {
trace!(
target: "babe",
"Verifying origin: {:?} header: {:?} justification: {:?} body: {:?}",
@@ -666,7 +666,7 @@ impl<B: BlockT, C> Verifier<B> for BabeVerifier<C> where
.log(|l| l.try_as_raw(OpaqueDigestItemId::Consensus(&BABE_ENGINE_ID)))
.map(|blob| vec![(well_known_cache_keys::AUTHORITIES, blob.to_vec())]);
let import_block = ImportBlock {
let import_block = BlockImportParams {
origin,
header: pre_header,
post_digests: vec![seal],
@@ -97,7 +97,7 @@ pub enum ForkChoiceStrategy {
}
/// Data required to import a Block
pub struct ImportBlock<Block: BlockT> {
pub struct BlockImportParams<Block: BlockT> {
/// Origin of the Block
pub origin: BlockOrigin,
/// The header, without consensus post-digests applied. This should be in the same
@@ -130,7 +130,7 @@ pub struct ImportBlock<Block: BlockT> {
pub fork_choice: ForkChoiceStrategy,
}
impl<Block: BlockT> ImportBlock<Block> {
impl<Block: BlockT> BlockImportParams<Block> {
/// Deconstruct the justified header into parts.
pub fn into_inner(self)
-> (
@@ -186,7 +186,7 @@ pub trait BlockImport<B: BlockT> {
/// Cached data can be accessed through the blockchain cache.
fn import_block(
&mut self,
block: ImportBlock<B>,
block: BlockImportParams<B>,
cache: HashMap<well_known_cache_keys::Id, Vec<u8>>,
) -> Result<ImportResult, Self::Error>;
}
@@ -206,7 +206,7 @@ where for<'r> &'r T: BlockImport<B, Error = E>
fn import_block(
&mut self,
block: ImportBlock<B>,
block: BlockImportParams<B>,
cache: HashMap<well_known_cache_keys::Id, Vec<u8>>,
) -> Result<ImportResult, Self::Error> {
(&**self).import_block(block, cache)
@@ -29,7 +29,7 @@ use std::{sync::Arc, collections::HashMap};
use runtime_primitives::{Justification, traits::{Block as BlockT, Header as _, NumberFor}};
use crate::{error::Error as ConsensusError, well_known_cache_keys::Id as CacheKeyId};
use crate::block_import::{
BlockImport, BlockOrigin, ImportBlock, ImportedAux, JustificationImport, ImportResult,
BlockImport, BlockOrigin, BlockImportParams, ImportedAux, JustificationImport, ImportResult,
FinalityProofImport,
};
@@ -67,7 +67,7 @@ pub struct IncomingBlock<B: BlockT> {
/// Verify a justification of a block
pub trait Verifier<B: BlockT>: Send + Sync {
/// Verify the given data and return the ImportBlock and an optional
/// Verify the given data and return the BlockImportParams and an optional
/// new set of validators to import. If not, err with an Error-Message
/// presented to the User in the logs.
fn verify(
@@ -76,7 +76,7 @@ pub trait Verifier<B: BlockT>: Send + Sync {
header: B::Header,
justification: Option<Justification>,
body: Option<Vec<B::Extrinsic>>,
) -> Result<(ImportBlock<B>, Option<Vec<(CacheKeyId, Vec<u8>)>>), String>;
) -> Result<(BlockImportParams<B>, Option<Vec<(CacheKeyId, Vec<u8>)>>), String>;
}
/// Blocks import queue API.
+1 -1
View File
@@ -47,7 +47,7 @@ const MAX_BLOCK_SIZE: usize = 4 * 1024 * 1024 + 512;
pub use self::error::Error;
pub use block_import::{
BlockImport, BlockOrigin, ForkChoiceStrategy, ImportedAux, ImportBlock, ImportResult,
BlockImport, BlockOrigin, ForkChoiceStrategy, ImportedAux, BlockImportParams, ImportResult,
JustificationImport, FinalityProofImport,
};
pub use select_chain::SelectChain;
+3 -3
View File
@@ -46,7 +46,7 @@ use consensus::error::{ErrorKind as CommonErrorKind};
use consensus::{Authorities, BlockImport, Environment, Proposer as BaseProposer};
use client::{Client as SubstrateClient, CallExecutor};
use client::runtime_api::{Core, BlockBuilder as BlockBuilderAPI, OldTxQueue, BlockBuilderError};
use runtime_primitives::generic::{BlockId, Era, ImportResult, ImportBlock, BlockOrigin};
use runtime_primitives::generic::{BlockId, Era, ImportResult, BlockImportParams, BlockOrigin};
use runtime_primitives::traits::{Block, Header};
use runtime_primitives::traits::{
Block as BlockT, Hash as HashT, Header as HeaderT,
@@ -391,7 +391,7 @@ impl<B, P, I, InStream, OutSink> Future for BftFuture<B, P, I, InStream, OutSink
justified_block.header().number(), hash);
let just: Justification = UncheckedJustification(committed.justification.uncheck()).into();
let (header, body) = justified_block.deconstruct();
let import_block = ImportBlock {
let import_block = BlockImportParams {
origin: BlockOrigin::ConsensusBroadcast,
header: header,
justification: Some(just),
@@ -1344,7 +1344,7 @@ mod tests {
type Error = Error;
fn import_block(&self,
block: ImportBlock<TestBlock>,
block: BlockImportParams<TestBlock>,
_new_authorities: Option<Vec<AuthorityId>>
) -> Result<ImportResult, Self::Error> {
assert!(self.imported_heights.lock().insert(block.header.number));