BABE refactoring: split out verification (#3658)

* Refactor parts of BABE verification into separate module

* Fix silly compiler error

* Move more of the verification code to verification.rs

* Remove some unused imports

* Fix line width

* fix testsuite compile error

* Fix compile errors in tests

* Move authorship-related code to its own files

* fix compile errors in tests

* Respond to review comments by @rphmeier

* improve docs

* fix compile error

* Add missing doc comment
This commit is contained in:
DemiMarie-parity
2019-10-02 09:51:49 -04:00
committed by Robert Habermeier
parent 3bfcdeb250
commit 8646cd158e
4 changed files with 482 additions and 427 deletions
+4 -2
View File
@@ -20,6 +20,7 @@
// https://github.com/paritytech/substrate/issues/2532
#![allow(deprecated)]
use super::*;
use authorship::claim_slot;
use babe_primitives::{AuthorityPair, SlotNumber};
use client::block_builder::BlockBuilder;
@@ -80,7 +81,7 @@ impl Environment<TestBlock> for DummyFactory {
-> Result<DummyProposer, Error>
{
let parent_slot = crate::find_pre_digest::<TestBlock>(parent_header)
let parent_slot = crate::find_pre_digest(parent_header)
.expect("parent header has a pre-digest")
.slot_number();
@@ -97,6 +98,7 @@ impl DummyProposer {
fn propose_with(&mut self, pre_digests: DigestFor<TestBlock>)
-> future::Ready<Result<TestBlock, Error>>
{
use codec::Encode;
let block_builder = self.factory.client.new_block_at(
&BlockId::Hash(self.parent_hash),
pre_digests,
@@ -106,7 +108,7 @@ impl DummyProposer {
Err(e) => return future::ready(Err(e)),
};
let this_slot = crate::find_pre_digest::<TestBlock>(block.header())
let this_slot = crate::find_pre_digest(block.header())
.expect("baked block has valid pre-digest")
.slot_number();