extract some grandpa types to Primitives crate (#12208)

* extract some grandpa types to primitives

* fmt

* fmt
This commit is contained in:
yjh
2022-09-13 05:34:43 +08:00
committed by GitHub
parent 967d790d5f
commit 472b5746e5
11 changed files with 197 additions and 125 deletions
@@ -354,7 +354,7 @@ fn warn_authority_wrong_target<H: ::std::fmt::Display>(hash: H, id: AuthorityId)
);
}
impl<Block: BlockT> BlockUntilImported<Block> for SignedMessage<Block> {
impl<Block: BlockT> BlockUntilImported<Block> for SignedMessage<Block::Header> {
type Blocked = Self;
fn needs_waiting<BlockStatus: BlockStatusT<Block>>(
@@ -389,8 +389,13 @@ impl<Block: BlockT> BlockUntilImported<Block> for SignedMessage<Block> {
/// Helper type definition for the stream which waits until vote targets for
/// signed messages are imported.
pub(crate) type UntilVoteTargetImported<Block, BlockStatus, BlockSyncRequester, I> =
UntilImported<Block, BlockStatus, BlockSyncRequester, I, SignedMessage<Block>>;
pub(crate) type UntilVoteTargetImported<Block, BlockStatus, BlockSyncRequester, I> = UntilImported<
Block,
BlockStatus,
BlockSyncRequester,
I,
SignedMessage<<Block as BlockT>::Header>,
>;
/// This blocks a global message import, i.e. a commit or catch up messages,
/// until all blocks referenced in its votes are known.
@@ -646,7 +651,7 @@ mod tests {
// unwrap the commit from `CommunicationIn` returning its fields in a tuple,
// panics if the given message isn't a commit
fn unapply_commit(msg: CommunicationIn<Block>) -> (u64, CompactCommit<Block>) {
fn unapply_commit(msg: CommunicationIn<Block>) -> (u64, CompactCommit<Header>) {
match msg {
voter::CommunicationIn::Commit(round, commit, ..) => (round, commit),
_ => panic!("expected commit"),
@@ -655,7 +660,7 @@ mod tests {
// unwrap the catch up from `CommunicationIn` returning its inner representation,
// panics if the given message isn't a catch up
fn unapply_catch_up(msg: CommunicationIn<Block>) -> CatchUp<Block> {
fn unapply_catch_up(msg: CommunicationIn<Block>) -> CatchUp<Header> {
match msg {
voter::CommunicationIn::CatchUp(catch_up, ..) => catch_up,
_ => panic!("expected catch up"),
@@ -740,7 +745,7 @@ mod tests {
let h2 = make_header(6);
let h3 = make_header(7);
let unknown_commit = CompactCommit::<Block> {
let unknown_commit = CompactCommit::<Header> {
target_hash: h1.hash(),
target_number: 5,
precommits: vec![
@@ -768,7 +773,7 @@ mod tests {
let h2 = make_header(6);
let h3 = make_header(7);
let known_commit = CompactCommit::<Block> {
let known_commit = CompactCommit::<Header> {
target_hash: h1.hash(),
target_number: 5,
precommits: vec![
@@ -910,7 +915,7 @@ mod tests {
// we create a commit message, with precommits for blocks 6 and 7 which
// we haven't imported.
let unknown_commit = CompactCommit::<Block> {
let unknown_commit = CompactCommit::<Header> {
target_hash: h1.hash(),
target_number: 5,
precommits: vec![