Trait frame_support::traits::tasks::Task

source ·
pub trait Task: Sized + FullCodec + TypeInfo + Clone + Debug + PartialEq + Eq {
    type Enumeration: Iterator;

    // Required methods
    fn iter() -> Self::Enumeration;
    fn is_valid(&self) -> bool;
    fn run(&self) -> Result<(), DispatchError>;
    fn weight(&self) -> Weight;
    fn task_index(&self) -> u32;
}
Expand description

A general-purpose trait which defines a type of service work (i.e., work to performed by an off-chain worker) including methods for enumerating, validating, indexing, and running tasks of this type.

Required Associated Types§

source

type Enumeration: Iterator

An Iterator over tasks of this type used as the return type for enumerate.

Required Methods§

source

fn iter() -> Self::Enumeration

Inspects the pallet’s state and enumerates tasks of this type.

source

fn is_valid(&self) -> bool

Checks if a particular instance of this Task variant is a valid piece of work.

This is used to validate tasks for unsigned execution. Hence, it MUST be cheap with minimal to no storage reads. Else, it can make the blockchain vulnerable to DoS attacks.

source

fn run(&self) -> Result<(), DispatchError>

Performs the work for this particular Task variant.

source

fn weight(&self) -> Weight

Returns the weight of executing this Task.

source

fn task_index(&self) -> u32

A unique value representing this Task within the current pallet. Analogous to call_index, but for tasks.’

This value should be unique within the current pallet and can overlap with task indices in other pallets.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Task for ()

Implementors§