pub fn if_else<T: Config>(
main: Box<<T as Config>::RuntimeCall>,
fallback: Box<<T as Config>::RuntimeCall>,
)
Expand description
Dispatch a fallback call in the event the main call fails to execute.
May be called from any origin except None
.
This function first attempts to dispatch the main
call.
If the main
call fails, the fallback
is attemted.
if the fallback is successfully dispatched, the weights of both calls
are accumulated and an event containing the main call error is deposited.
In the event of a fallback failure the whole call fails with the weights returned.
main
: The main call to be dispatched. This is the primary action to execute.fallback
: The fallback call to be dispatched in case themain
call fails.
§Dispatch Logic
- If the origin is
root
, both the main and fallback calls are executed without applying any origin filters. - If the origin is not
root
, the origin filter is applied to both themain
andfallback
calls.
§Use Case
- Some use cases might involve submitting a
batch
type call in either main, fallback or both.
§Warning: Doc-Only
This function is an automatically generated, and is doc-only, uncallable
stub. See the real version in
Pallet::if_else
.