node: setup disabled grandpa properly (#3356)

This commit is contained in:
André Silva
2019-08-09 15:53:44 +01:00
committed by Robert Habermeier
parent 98d502466d
commit 59c88cb2f3
3 changed files with 53 additions and 11 deletions
@@ -554,6 +554,28 @@ impl<B: BlockT> ConsensusGossip<B> {
}
}
/// A gossip message validator that discards all messages.
pub struct DiscardAll;
impl<B: BlockT> Validator<B> for DiscardAll {
fn validate(
&self,
_context: &mut dyn ValidatorContext<B>,
_sender: &PeerId,
_data: &[u8],
) -> ValidationResult<B::Hash> {
ValidationResult::Discard
}
fn message_expired<'a>(&'a self) -> Box<dyn FnMut(B::Hash, &[u8]) -> bool + 'a> {
Box::new(move |_topic, _data| true)
}
fn message_allowed<'a>(&'a self) -> Box<dyn FnMut(&PeerId, MessageIntent, &B::Hash, &[u8]) -> bool + 'a> {
Box::new(move |_who, _intent, _topic, _data| false)
}
}
#[cfg(test)]
mod tests {
use sr_primitives::testing::{H256, Block as RawBlock, ExtrinsicWrapper};