network: don't force send block announcements (#7601)

This commit is contained in:
André Silva
2020-11-27 22:37:38 +00:00
committed by GitHub
parent 8c7d217091
commit 96461be248
+2 -7
View File
@@ -1083,16 +1083,11 @@ impl<B: BlockT, H: ExHashT> Protocol<B, H> {
let is_best = self.context_data.chain.info().best_hash == hash;
debug!(target: "sync", "Reannouncing block {:?} is_best: {}", hash, is_best);
self.send_announcement(&header, data, is_best, true)
}
fn send_announcement(&mut self, header: &B::Header, data: Vec<u8>, is_best: bool, force: bool) {
let hash = header.hash();
for (who, ref mut peer) in self.context_data.peers.iter_mut() {
trace!(target: "sync", "Announcing block {:?} to {}", hash, who);
let inserted = peer.known_blocks.insert(hash);
if inserted || force {
if inserted {
trace!(target: "sync", "Announcing block {:?} to {}", hash, who);
let message = message::BlockAnnounce {
header: header.clone(),
state: if is_best {