mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 18:07:58 +00:00
Move block announcement protocol config out of Protocol (#12441)
* Move Role(s) to `sc-network-common` * Introduce `NotificationHandshake` type * Move block announce protocol config creation to `ChainSync` * Include block announcement into `notification_protocols` * Apply review comments * Remove unneeded include * Add missing include * Apply review comments
This commit is contained in:
@@ -19,10 +19,12 @@
|
||||
//! Network packet message types. These get serialized and put into the lower level protocol
|
||||
//! payload.
|
||||
|
||||
use crate::protocol::role::Roles;
|
||||
|
||||
use bitflags::bitflags;
|
||||
use codec::{Decode, Encode, Error, Input, Output};
|
||||
pub use generic::{BlockAnnounce, FromBlock};
|
||||
use sp_runtime::traits::{Block as BlockT, Header as HeaderT};
|
||||
use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor};
|
||||
|
||||
/// Type alias for using the block request type using block type parameters.
|
||||
pub type BlockRequest<B> =
|
||||
@@ -218,3 +220,27 @@ pub mod generic {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Handshake sent when we open a block announces substream.
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Encode, Decode)]
|
||||
pub struct BlockAnnouncesHandshake<B: BlockT> {
|
||||
/// Roles of the node.
|
||||
pub roles: Roles,
|
||||
/// Best block number.
|
||||
pub best_number: NumberFor<B>,
|
||||
/// Best block hash.
|
||||
pub best_hash: B::Hash,
|
||||
/// Genesis block hash.
|
||||
pub genesis_hash: B::Hash,
|
||||
}
|
||||
|
||||
impl<B: BlockT> BlockAnnouncesHandshake<B> {
|
||||
pub fn build(
|
||||
roles: Roles,
|
||||
best_number: NumberFor<B>,
|
||||
best_hash: B::Hash,
|
||||
genesis_hash: B::Hash,
|
||||
) -> Self {
|
||||
Self { genesis_hash, roles, best_number, best_hash }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user