Skip to content

Commit

Permalink
Clean up Justification struct, Issue paritytech#1033
Browse files Browse the repository at this point in the history
  • Loading branch information
shawntabrizi committed Nov 12, 2018
1 parent d45de4b commit aecf358
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
10 changes: 5 additions & 5 deletions core/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -909,8 +909,8 @@ impl<B, E, Block> consensus::BlockImport<Block> for Client<B, E, Block> where
let ImportBlock {
origin,
header,
external_justification,
post_runtime_digests,
justification,
post_digests,
body,
finalized,
..
Expand All @@ -922,11 +922,11 @@ impl<B, E, Block> consensus::BlockImport<Block> for Client<B, E, Block> where
blockchain::BlockStatus::Unknown => return Ok(ImportResult::UnknownParent),
}

let import_headers = if post_runtime_digests.is_empty() {
let import_headers = if post_digests.is_empty() {
PrePostHeader::Same(header)
} else {
let mut post_header = header.clone();
for item in post_runtime_digests {
for item in post_digests {
post_header.digest_mut().push(item);
}
PrePostHeader::Different(header, post_header)
Expand All @@ -941,7 +941,7 @@ impl<B, E, Block> consensus::BlockImport<Block> for Client<B, E, Block> where
origin,
hash,
import_headers,
external_justification,
justification,
body,
new_authorities,
finalized,
Expand Down
8 changes: 4 additions & 4 deletions core/consensus/aura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ pub fn start_aura<B, C, E, SO, Error>(
let import_block = ImportBlock {
origin: BlockOrigin::Own,
header,
external_justification: Vec::new(),
post_runtime_digests: vec![item],
justification: Vec::new(),
post_digests: vec![item],
body: Some(body),
finalized: false,
auxiliary: Vec::new(),
Expand Down Expand Up @@ -380,8 +380,8 @@ impl<B: Block, C> Verifier<B> for AuraVerifier<C> where
let import_block = ImportBlock {
origin,
header: pre_header,
external_justification: Vec::new(),
post_runtime_digests: vec![item],
justification: Vec::new(),
post_digests: vec![item],
body,
finalized: false,
auxiliary: Vec::new(),
Expand Down
10 changes: 5 additions & 5 deletions core/consensus/common/src/block_import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ pub struct ImportBlock<Block: BlockT> {
///
/// Consensus engines which alter the header (by adding post-runtime digests)
/// should strip those off in the initial verification process and pass them
/// via the `post_runtime_digests` field. During block authorship, they should
/// via the `post_digests` field. During block authorship, they should
/// not be pushed to the header directly.
///
/// The reason for this distinction is so the header can be directly
/// re-executed in a runtime that checks digest equivalence -- the
/// post-runtime digests are pushed back on after.
pub header: Block::Header,
/// Justification provided for this block from the outside:.
pub external_justification: Justification,
pub justification: Justification,
/// Digest items that have been added after the runtime for external
/// work, like a consensus signature.
pub post_runtime_digests: Vec<DigestItemFor<Block>>,
pub post_digests: Vec<DigestItemFor<Block>>,
/// Block's body
pub body: Option<Vec<Block::Extrinsic>>,
/// Is this block finalized already?
Expand All @@ -82,8 +82,8 @@ impl<Block: BlockT> ImportBlock<Block> {
(
self.origin,
self.header,
self.external_justification,
self.post_runtime_digests,
self.justification,
self.post_digests,
self.body,
self.finalized,
self.auxiliary,
Expand Down
4 changes: 2 additions & 2 deletions core/consensus/rhd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,10 +419,10 @@ impl<B, P, I, InStream, OutSink> Future for BftFuture<B, P, I, InStream, OutSink
let import_block = ImportBlock {
origin: BlockOrigin::ConsensusBroadcast,
header: header,
external_justification: just.into(),
justification: just.into(),
body: Some(body),
finalized: true,
post_runtime_digests: Default::default(),
post_digests: Default::default(),
auxiliary: Default::default()
};

Expand Down
4 changes: 2 additions & 2 deletions core/network/src/import_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,8 @@ impl<B: BlockT> Verifier<B> for PassThroughVerifier {
header,
body,
finalized: self.0,
external_justification: justification,
post_runtime_digests: vec![],
justification: justification,
post_digests: vec![],
auxiliary: Vec::new(),
}, None))
}
Expand Down
4 changes: 2 additions & 2 deletions core/test-client/src/client_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ impl<B, E> TestClient for Client<B, E, runtime::Block>
let import = ImportBlock {
origin,
header: block.header,
external_justification: vec![],
post_runtime_digests: vec![],
justification: vec![],
post_digests: vec![],
body: Some(block.extrinsics),
finalized: false,
auxiliary: Vec::new(),
Expand Down
2 changes: 1 addition & 1 deletion node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ mod tests {
let block = proposer.propose().expect("Error making test block");
ImportBlock {
origin: BlockOrigin::File,
external_justification: Vec::new(),
justification: Vec::new(),
internal_justification: Vec::new(),
finalized: true,
body: Some(block.extrinsics),
Expand Down

0 comments on commit aecf358

Please sign in to comment.