mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 22:11:02 +00:00
allow empty data
This commit is contained in:
@@ -35,6 +35,8 @@ use std::marker::PhantomData;
|
|||||||
/// valid parachain-block candidate.
|
/// valid parachain-block candidate.
|
||||||
/// Data encoding is just `GossipMessage`, the relay-chain validator candidate statement message is
|
/// Data encoding is just `GossipMessage`, the relay-chain validator candidate statement message is
|
||||||
/// the justification.
|
/// the justification.
|
||||||
|
///
|
||||||
|
/// Note: if no justification is provided the annouce is considered valid.
|
||||||
pub struct JustifiedBlockAnnounceValidator<B> {
|
pub struct JustifiedBlockAnnounceValidator<B> {
|
||||||
authorities: Vec<ValidatorId>,
|
authorities: Vec<ValidatorId>,
|
||||||
phantom: PhantomData<B>,
|
phantom: PhantomData<B>,
|
||||||
@@ -53,6 +55,11 @@ impl<B: BlockT> BlockAnnounceValidator<B> for JustifiedBlockAnnounceValidator<B>
|
|||||||
fn validate(&mut self, header: &B::Header, mut data: &[u8])
|
fn validate(&mut self, header: &B::Header, mut data: &[u8])
|
||||||
-> Result<Validation, Box<dyn std::error::Error + Send>>
|
-> Result<Validation, Box<dyn std::error::Error + Send>>
|
||||||
{
|
{
|
||||||
|
// If no data is provided the announce is valid.
|
||||||
|
if data.is_empty() {
|
||||||
|
return Ok(Validation::Success)
|
||||||
|
}
|
||||||
|
|
||||||
// Check data is a gossip message.
|
// Check data is a gossip message.
|
||||||
let gossip_message = GossipMessage::decode(&mut data)
|
let gossip_message = GossipMessage::decode(&mut data)
|
||||||
.map_err(|_| Box::new(ClientError::BadJustification(
|
.map_err(|_| Box::new(ClientError::BadJustification(
|
||||||
|
|||||||
Reference in New Issue
Block a user