2

In this question, and this answer the difference between batch and batch_all are discussed, but there is a third similar function in the utility pallet force_batch

What are the key differences between batch batch-all and force-batch

2 Answers 2

1

The key differences are:

  • batch_all: Stops on error and reverts everything (all-or-nothing).
  • force_batch: Does not stop on error and only reverts the failed calls (keep-going).
  • batch: Stops on error and only reverts the first failed call (fail-fast).
3
  • 1
    Your answer was a bit more on the spot I have accepted it.
    – Simson
    Nov 6, 2023 at 0:35
  • Thanks. I think we should add your Q as FAQ to the pallet docs. It seems to come up often. Nov 6, 2023 at 0:35
  • I'm using this in one of my projects, yet I fail to remember why and have to read it carefully every time.
    – Simson
    Nov 6, 2023 at 0:38
0

From the documentation:

batch The docs are not very helpful yet:

Send a batch of dispatch calls

batch_all

Here the doc give us some clue

Send a batch of dispatch calls and atomically execute them. The whole transaction will rollback and fail if any of the calls failed.

force_batch The docs finally touches the key differences

Send a batch of dispatch calls. Unlike batch, it allows errors and won’t interrupt.

So in short the key differences are:

  1. batch will run all parts until it encounters an error then stop
  2. batch_all will run all parts but roll back all if there is an error
  3. force_batch will continue execute the rest of the parts even if some part failed.

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.