mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 23:47:56 +00:00
Limit number of uncles that can be provided. (#4298)
* Limit number of uncles that can be provided. * Check length of uncles vector on inherent. * Set fatal error to true for too many uncles. * Take max uncles in create_inherent.
This commit is contained in:
@@ -21,11 +21,27 @@
|
||||
use rstd::{result::Result, prelude::*};
|
||||
|
||||
use codec::{Encode, Decode};
|
||||
use sp_inherents::{Error, InherentIdentifier, InherentData};
|
||||
use sp_inherents::{Error, InherentIdentifier, InherentData, IsFatalError};
|
||||
use sr_primitives::RuntimeString;
|
||||
|
||||
/// The identifier for the `uncles` inherent.
|
||||
pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"uncles00";
|
||||
|
||||
/// Errors that can occur while checking the authorship inherent.
|
||||
#[derive(Encode, sr_primitives::RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Decode))]
|
||||
pub enum InherentError {
|
||||
Uncles(RuntimeString),
|
||||
}
|
||||
|
||||
impl IsFatalError for InherentError {
|
||||
fn is_fatal_error(&self) -> bool {
|
||||
match self {
|
||||
InherentError::Uncles(_) => true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Auxiliary trait to extract uncles inherent data.
|
||||
pub trait UnclesInherentData<H: Decode> {
|
||||
/// Get uncles.
|
||||
|
||||
Reference in New Issue
Block a user