Skip to content
Snippets Groups Projects
Commit 18ec2d14 authored by Marcio Diaz's avatar Marcio Diaz Committed by GitHub
Browse files

Fix grandpa issue for InvalidViewChanges (#2468)

* fix: add message_allowed to send_topic to avoid InvalidViewChanges

* fix: this should be strict

* fix typo

* fix: simplify
parent 32c85a61
No related merge requests found
......@@ -445,11 +445,22 @@ impl<B: BlockT> ConsensusGossip<B> {
/// Send all messages with given topic to a peer.
pub fn send_topic(&mut self, protocol: &mut Context<B>, who: &PeerId, topic: B::Hash, engine_id: ConsensusEngineId, force: bool) {
let validator = self.validators.get(&engine_id);
let mut message_allowed = match validator {
None => return, // treat all messages with no validator as not allowed
Some(validator) => validator.message_allowed(),
};
let intent = if force { MessageIntent::ForcedBroadcast } else { MessageIntent::Broadcast };
if let Some(ref mut peer) = self.peers.get_mut(who) {
for entry in self.messages.iter().filter(|m| m.topic == topic && m.message.engine_id == engine_id) {
if !force && peer.known_messages.contains(&entry.message_hash) {
continue
}
if !message_allowed(who, intent, &entry.topic, &entry.message.data) {
continue
}
peer.known_messages.insert(entry.message_hash.clone());
trace!(target: "gossip", "Sending topic message to {}: {:?}", who, entry.message);
protocol.send_consensus(who.clone(), ConsensusMessage {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment