1

I am looking to process deletions in batches yet avoid using on_initialize(). Can I submit an inherent from the call to process next batch in a subsequent block? If so, what would the code to create/submit the inherent look like?

    let LIMIT = 256;

    pub fn delete(origin: OriginFor<T>, id:u32) -> DispatchResult {
        let who = ensure_signed(origin)?;

        let items = getItemsFromStorage(id);
        let num_items = items.count();
        let num_deleted = remove_items_for(items, LIMIT);
        if (num_deleted < num_items) {
          // Create and submit inherent to delete/remove the remainder of the items
          //
          // Inherent: delete_remaining_items_for(id);
          // 
        }

        Ok(())
    }

2 Answers 2

1

You can use on_idle if you want to avoid on_initialize.

0

Inherents

Typically, this type of transaction is not gossiped to other nodes or stored in the transaction queue. The data inserted using an inherent transaction is assumed to be valid without requiring specific validation.

Given that you probably want to gossip about this transaction so that it is verified among all collators. Perhaps, inherent is probably not the ideal solution for this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.