mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-01 03:21:02 +00:00
extract some grandpa types to Primitives crate (#12208)
* extract some grandpa types to primitives * fmt * fmt
This commit is contained in:
@@ -350,7 +350,7 @@ pub(super) struct VoteMessage<Block: BlockT> {
|
||||
/// The voter set ID this message is from.
|
||||
pub(super) set_id: SetId,
|
||||
/// The message itself.
|
||||
pub(super) message: SignedMessage<Block>,
|
||||
pub(super) message: SignedMessage<Block::Header>,
|
||||
}
|
||||
|
||||
/// Network level commit message with topic information.
|
||||
@@ -361,7 +361,7 @@ pub(super) struct FullCommitMessage<Block: BlockT> {
|
||||
/// The voter set ID this message is from.
|
||||
pub(super) set_id: SetId,
|
||||
/// The compact commit message.
|
||||
pub(super) message: CompactCommit<Block>,
|
||||
pub(super) message: CompactCommit<Block::Header>,
|
||||
}
|
||||
|
||||
/// V1 neighbor packet. Neighbor packets are sent from nodes to their peers
|
||||
@@ -406,7 +406,7 @@ pub(super) struct FullCatchUpMessage<Block: BlockT> {
|
||||
/// The voter set ID this message is from.
|
||||
pub(super) set_id: SetId,
|
||||
/// The compact commit message.
|
||||
pub(super) message: CatchUp<Block>,
|
||||
pub(super) message: CatchUp<Block::Header>,
|
||||
}
|
||||
|
||||
/// Misbehavior that peers can perform.
|
||||
@@ -1071,7 +1071,7 @@ impl<Block: BlockT> Inner<Block> {
|
||||
|
||||
let (base_hash, base_number) = last_completed_round.base;
|
||||
|
||||
let catch_up = CatchUp::<Block> {
|
||||
let catch_up = CatchUp::<Block::Header> {
|
||||
round_number: last_completed_round.number,
|
||||
prevotes,
|
||||
precommits,
|
||||
@@ -1651,8 +1651,8 @@ mod tests {
|
||||
use crate::communication;
|
||||
use sc_network::config::Role;
|
||||
use sc_network_gossip::Validator as GossipValidatorT;
|
||||
use sc_network_test::Block;
|
||||
use sp_core::{crypto::UncheckedFrom, H256};
|
||||
use substrate_test_runtime_client::runtime::{Block, Header};
|
||||
|
||||
// some random config (not really needed)
|
||||
fn config() -> crate::Config {
|
||||
@@ -1856,7 +1856,7 @@ mod tests {
|
||||
&VoteMessage {
|
||||
round: Round(1),
|
||||
set_id: SetId(set_id),
|
||||
message: SignedMessage::<Block> {
|
||||
message: SignedMessage::<Header> {
|
||||
message: finality_grandpa::Message::Prevote(finality_grandpa::Prevote {
|
||||
target_hash: Default::default(),
|
||||
target_number: 10,
|
||||
@@ -1872,7 +1872,7 @@ mod tests {
|
||||
&VoteMessage {
|
||||
round: Round(1),
|
||||
set_id: SetId(set_id),
|
||||
message: SignedMessage::<Block> {
|
||||
message: SignedMessage::<Header> {
|
||||
message: finality_grandpa::Message::Prevote(finality_grandpa::Prevote {
|
||||
target_hash: Default::default(),
|
||||
target_number: 10,
|
||||
@@ -1943,7 +1943,7 @@ mod tests {
|
||||
votes: Default::default(),
|
||||
});
|
||||
|
||||
let mut current_rounds = environment::CurrentRounds::new();
|
||||
let mut current_rounds = environment::CurrentRounds::<Block>::new();
|
||||
current_rounds.insert(3, environment::HasVoted::No);
|
||||
|
||||
let set_state =
|
||||
|
||||
@@ -312,8 +312,8 @@ impl<B: BlockT, N: Network<B>> NetworkBridge<B, N> {
|
||||
round: Round,
|
||||
set_id: SetId,
|
||||
voters: Arc<VoterSet<AuthorityId>>,
|
||||
has_voted: HasVoted<B>,
|
||||
) -> (impl Stream<Item = SignedMessage<B>> + Unpin, OutgoingMessages<B>) {
|
||||
has_voted: HasVoted<B::Header>,
|
||||
) -> (impl Stream<Item = SignedMessage<B::Header>> + Unpin, OutgoingMessages<B>) {
|
||||
self.note_round(round, set_id, &voters);
|
||||
|
||||
let keystore = keystore.and_then(|ks| {
|
||||
@@ -675,15 +675,15 @@ pub(crate) struct OutgoingMessages<Block: BlockT> {
|
||||
round: RoundNumber,
|
||||
set_id: SetIdNumber,
|
||||
keystore: Option<LocalIdKeystore>,
|
||||
sender: mpsc::Sender<SignedMessage<Block>>,
|
||||
sender: mpsc::Sender<SignedMessage<Block::Header>>,
|
||||
network: Arc<Mutex<GossipEngine<Block>>>,
|
||||
has_voted: HasVoted<Block>,
|
||||
has_voted: HasVoted<Block::Header>,
|
||||
telemetry: Option<TelemetryHandle>,
|
||||
}
|
||||
|
||||
impl<B: BlockT> Unpin for OutgoingMessages<B> {}
|
||||
|
||||
impl<Block: BlockT> Sink<Message<Block>> for OutgoingMessages<Block> {
|
||||
impl<Block: BlockT> Sink<Message<Block::Header>> for OutgoingMessages<Block> {
|
||||
type Error = Error;
|
||||
|
||||
fn poll_ready(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
@@ -694,7 +694,10 @@ impl<Block: BlockT> Sink<Message<Block>> for OutgoingMessages<Block> {
|
||||
})
|
||||
}
|
||||
|
||||
fn start_send(mut self: Pin<&mut Self>, mut msg: Message<Block>) -> Result<(), Self::Error> {
|
||||
fn start_send(
|
||||
mut self: Pin<&mut Self>,
|
||||
mut msg: Message<Block::Header>,
|
||||
) -> Result<(), Self::Error> {
|
||||
// if we've voted on this round previously under the same key, send that vote instead
|
||||
match &mut msg {
|
||||
finality_grandpa::Message::PrimaryPropose(ref mut vote) => {
|
||||
@@ -784,7 +787,7 @@ impl<Block: BlockT> Sink<Message<Block>> for OutgoingMessages<Block> {
|
||||
// checks a compact commit. returns the cost associated with processing it if
|
||||
// the commit was bad.
|
||||
fn check_compact_commit<Block: BlockT>(
|
||||
msg: &CompactCommit<Block>,
|
||||
msg: &CompactCommit<Block::Header>,
|
||||
voters: &VoterSet<AuthorityId>,
|
||||
round: Round,
|
||||
set_id: SetId,
|
||||
@@ -852,7 +855,7 @@ fn check_compact_commit<Block: BlockT>(
|
||||
// checks a catch up. returns the cost associated with processing it if
|
||||
// the catch up was bad.
|
||||
fn check_catch_up<Block: BlockT>(
|
||||
msg: &CatchUp<Block>,
|
||||
msg: &CatchUp<Block::Header>,
|
||||
voters: &VoterSet<AuthorityId>,
|
||||
set_id: SetId,
|
||||
telemetry: Option<TelemetryHandle>,
|
||||
@@ -902,7 +905,7 @@ fn check_catch_up<Block: BlockT>(
|
||||
) -> Result<usize, ReputationChange>
|
||||
where
|
||||
B: BlockT,
|
||||
I: Iterator<Item = (Message<B>, &'a AuthorityId, &'a AuthoritySignature)>,
|
||||
I: Iterator<Item = (Message<B::Header>, &'a AuthorityId, &'a AuthoritySignature)>,
|
||||
{
|
||||
use crate::communication::gossip::Misbehavior;
|
||||
|
||||
@@ -996,7 +999,7 @@ impl<Block: BlockT> CommitsOut<Block> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<Block: BlockT> Sink<(RoundNumber, Commit<Block>)> for CommitsOut<Block> {
|
||||
impl<Block: BlockT> Sink<(RoundNumber, Commit<Block::Header>)> for CommitsOut<Block> {
|
||||
type Error = Error;
|
||||
|
||||
fn poll_ready(self: Pin<&mut Self>, _: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||
@@ -1005,7 +1008,7 @@ impl<Block: BlockT> Sink<(RoundNumber, Commit<Block>)> for CommitsOut<Block> {
|
||||
|
||||
fn start_send(
|
||||
self: Pin<&mut Self>,
|
||||
input: (RoundNumber, Commit<Block>),
|
||||
input: (RoundNumber, Commit<Block::Header>),
|
||||
) -> Result<(), Self::Error> {
|
||||
if !self.is_voter {
|
||||
return Ok(())
|
||||
@@ -1027,7 +1030,7 @@ impl<Block: BlockT> Sink<(RoundNumber, Commit<Block>)> for CommitsOut<Block> {
|
||||
.map(|signed| (signed.precommit, (signed.signature, signed.id)))
|
||||
.unzip();
|
||||
|
||||
let compact_commit = CompactCommit::<Block> {
|
||||
let compact_commit = CompactCommit::<Block::Header> {
|
||||
target_hash: commit.target_hash,
|
||||
target_number: commit.target_number,
|
||||
precommits,
|
||||
|
||||
Reference in New Issue
Block a user