pub trait Validator<B: BlockT>: Send + Sync {
// Required method
fn validate(
&self,
context: &mut dyn ValidatorContext<B>,
sender: &PeerId,
data: &[u8],
) -> ValidationResult<B::Hash>;
// Provided methods
fn new_peer(
&self,
_context: &mut dyn ValidatorContext<B>,
_who: &PeerId,
_role: ObservedRole,
) { ... }
fn peer_disconnected(
&self,
_context: &mut dyn ValidatorContext<B>,
_who: &PeerId,
) { ... }
fn message_expired<'a>(
&'a self,
) -> Box<dyn FnMut(B::Hash, &[u8]) -> bool + 'a> { ... }
fn message_allowed<'a>(
&'a self,
) -> Box<dyn FnMut(&PeerId, MessageIntent, &B::Hash, &[u8]) -> bool + 'a> { ... }
}
Expand description
Validates consensus messages.
Required Methods§
sourcefn validate(
&self,
context: &mut dyn ValidatorContext<B>,
sender: &PeerId,
data: &[u8],
) -> ValidationResult<B::Hash>
fn validate( &self, context: &mut dyn ValidatorContext<B>, sender: &PeerId, data: &[u8], ) -> ValidationResult<B::Hash>
Validate consensus message.
Provided Methods§
sourcefn new_peer(
&self,
_context: &mut dyn ValidatorContext<B>,
_who: &PeerId,
_role: ObservedRole,
)
fn new_peer( &self, _context: &mut dyn ValidatorContext<B>, _who: &PeerId, _role: ObservedRole, )
New peer is connected.
sourcefn peer_disconnected(
&self,
_context: &mut dyn ValidatorContext<B>,
_who: &PeerId,
)
fn peer_disconnected( &self, _context: &mut dyn ValidatorContext<B>, _who: &PeerId, )
New connection is dropped.
sourcefn message_expired<'a>(&'a self) -> Box<dyn FnMut(B::Hash, &[u8]) -> bool + 'a>
fn message_expired<'a>(&'a self) -> Box<dyn FnMut(B::Hash, &[u8]) -> bool + 'a>
Produce a closure for validating messages on a given topic.
sourcefn message_allowed<'a>(
&'a self,
) -> Box<dyn FnMut(&PeerId, MessageIntent, &B::Hash, &[u8]) -> bool + 'a>
fn message_allowed<'a>( &'a self, ) -> Box<dyn FnMut(&PeerId, MessageIntent, &B::Hash, &[u8]) -> bool + 'a>
Produce a closure for filtering egress messages.