put the validate_unsigned implementation inside the pallet definition (#9044)

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
Guillaume Thiolliere
2021-06-08 22:54:06 +02:00
committed by GitHub
parent c7b9430b7f
commit ea6831e398
4 changed files with 38 additions and 14 deletions
+7 -7
View File
@@ -200,12 +200,12 @@ pub struct GrandpaTimeSlot {
pub round: RoundNumber,
}
/// A `ValidateUnsigned` implementation that restricts calls to `report_equivocation_unsigned`
/// to local calls (i.e. extrinsics generated on this node) or that already in a block. This
/// guarantees that only block authors can include unsigned equivocation reports.
impl<T: Config> frame_support::unsigned::ValidateUnsigned for Pallet<T> {
type Call = Call<T>;
fn validate_unsigned(source: TransactionSource, call: &Self::Call) -> TransactionValidity {
/// Methods for the `ValidateUnsigned` implementation:
/// It restricts calls to `report_equivocation_unsigned` to local calls (i.e. extrinsics generated
/// on this node) or that already in a block. This guarantees that only block authors can include
/// unsigned equivocation reports.
impl<T: Config> Pallet<T> {
pub fn validate_unsigned(source: TransactionSource, call: &Call<T>) -> TransactionValidity {
if let Call::report_equivocation_unsigned(equivocation_proof, key_owner_proof) = call {
// discard equivocation report not coming from the local node
match source {
@@ -243,7 +243,7 @@ impl<T: Config> frame_support::unsigned::ValidateUnsigned for Pallet<T> {
}
}
fn pre_dispatch(call: &Self::Call) -> Result<(), TransactionValidityError> {
pub fn pre_dispatch(call: &Call<T>) -> Result<(), TransactionValidityError> {
if let Call::report_equivocation_unsigned(equivocation_proof, key_owner_proof) = call {
is_known_offence::<T>(equivocation_proof, key_owner_proof)
} else {