mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 12:11:09 +00:00
Sync: Propagate block announcement data (#7903)
* Sync: Propagate block announcement data This pr adds a feature to the sync protocol to propagate the data that we received alongside a block announcement. This is done by adding a cache that caches the last X block announcement data where X is set to the number of `in_peers` (giving every peer the chance to send us a different block). This will be required by parachains to ensure that even peers who are not connected to a collator receive the data alongside the block announcement to properly validate it and request the block. * Review comment * Bring back the code and add new variant to ensure we don't insert block announce data when something wasn't checked * Also use out_peers
This commit is contained in:
@@ -166,7 +166,7 @@ impl<B: BlockT> GossipEngine<B> {
|
||||
///
|
||||
/// Note: this method isn't strictly related to gossiping and should eventually be moved
|
||||
/// somewhere else.
|
||||
pub fn announce(&self, block: B::Hash, associated_data: Vec<u8>) {
|
||||
pub fn announce(&self, block: B::Hash, associated_data: Option<Vec<u8>>) {
|
||||
self.network.announce(block, associated_data);
|
||||
}
|
||||
}
|
||||
@@ -347,7 +347,7 @@ mod tests {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn announce(&self, _: B::Hash, _: Vec<u8>) {
|
||||
fn announce(&self, _: B::Hash, _: Option<Vec<u8>>) {
|
||||
unimplemented!();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ pub trait Network<B: BlockT> {
|
||||
///
|
||||
/// Note: this method isn't strictly related to gossiping and should eventually be moved
|
||||
/// somewhere else.
|
||||
fn announce(&self, block: B::Hash, associated_data: Vec<u8>);
|
||||
fn announce(&self, block: B::Hash, associated_data: Option<Vec<u8>>);
|
||||
}
|
||||
|
||||
impl<B: BlockT, H: ExHashT> Network<B> for Arc<NetworkService<B, H>> {
|
||||
@@ -136,7 +136,7 @@ impl<B: BlockT, H: ExHashT> Network<B> for Arc<NetworkService<B, H>> {
|
||||
NetworkService::write_notification(self, who, protocol, message)
|
||||
}
|
||||
|
||||
fn announce(&self, block: B::Hash, associated_data: Vec<u8>) {
|
||||
fn announce(&self, block: B::Hash, associated_data: Option<Vec<u8>>) {
|
||||
NetworkService::announce_block(self, block, associated_data)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -570,7 +570,7 @@ mod tests {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn announce(&self, _: B::Hash, _: Vec<u8>) {
|
||||
fn announce(&self, _: B::Hash, _: Option<Vec<u8>>) {
|
||||
unimplemented!();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user