Trait frame_support::inherent::ProvideInherent
source · [−]pub trait ProvideInherent {
type Call;
type Error: Encode + IsFatalError;
const INHERENT_IDENTIFIER: InherentIdentifier;
fn create_inherent(data: &InherentData) -> Option<Self::Call>;
fn is_inherent(call: &Self::Call) -> bool;
fn is_inherent_required(
_: &InherentData
) -> Result<Option<Self::Error>, Self::Error> { ... }
fn check_inherent(
_: &Self::Call,
_: &InherentData
) -> Result<(), Self::Error> { ... }
}
Expand description
A pallet that provides or verifies an inherent extrinsic.
The pallet may provide the inherent, verify an inherent, or both provide and verify.
Associated Types
type Error: Encode + IsFatalError
type Error: Encode + IsFatalError
The error returned by check_inherent
.
Associated Constants
The inherent identifier used by this inherent.
Required methods
fn create_inherent(data: &InherentData) -> Option<Self::Call>
fn create_inherent(data: &InherentData) -> Option<Self::Call>
Create an inherent out of the given InherentData
.
fn is_inherent(call: &Self::Call) -> bool
fn is_inherent(call: &Self::Call) -> bool
Return whether the call is an inherent call.
NOTE: Signed extrinsics are not inherent, but signed extrinsic with the given call variant can be dispatched.
Warning
In FRAME, inherent are enforced to be before other extrinsics, for this reason,
pallets with unsigned transactions must ensure that no unsigned transaction call
is an inherent call, when implementing ValidateUnsigned::validate_unsigned
.
Otherwise block producer can produce invalid blocks by including them after non inherent.
Provided methods
fn is_inherent_required(
_: &InherentData
) -> Result<Option<Self::Error>, Self::Error>
fn is_inherent_required(
_: &InherentData
) -> Result<Option<Self::Error>, Self::Error>
Determines whether this inherent is required in this block.
-
Ok(None)
indicates that this inherent is not required in this block. The default implementation returns this. -
Ok(Some(e))
indicates that this inherent is required in this block.construct_runtime!
will call this function from in its implementation offn check_extrinsics
. If the inherent is not present, it will returne
. -
Err(_)
indicates that this function failed and further operations should be aborted.
NOTE: If inherent is required then the runtime asserts that the block contains at least one inherent for which:
- type is
Self::Call
, Self::is_inherent
returns true.
fn check_inherent(_: &Self::Call, _: &InherentData) -> Result<(), Self::Error>
fn check_inherent(_: &Self::Call, _: &InherentData) -> Result<(), Self::Error>
Check whether the given inherent is valid. Checking the inherent is optional and can be omitted by using the default implementation.
When checking an inherent, the first parameter represents the inherent that is actually included in the block by its author. Whereas the second parameter represents the inherent data that the verifying node calculates.
NOTE: A block can contains multiple inherent.