From 0b1ee1b068c78b26e4bbb1c4991db0442fdc1cc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Wed, 5 Apr 2023 14:14:46 +0100 Subject: [PATCH] Mention `on_idle` round-robin logic to `trait Hooks` cargo doc (#13797) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Adds on_idle round-robin logic to trait Hooks docs * Makes the docs more concise * Update frame/support/src/traits/hooks.rs Co-authored-by: Bastian Köcher * fmt --------- Co-authored-by: Bastian Köcher --- frame/support/src/traits/hooks.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/frame/support/src/traits/hooks.rs b/frame/support/src/traits/hooks.rs index a3374d0bf537f..2d346ccd38a8b 100644 --- a/frame/support/src/traits/hooks.rs +++ b/frame/support/src/traits/hooks.rs @@ -227,10 +227,15 @@ pub trait Hooks { fn on_finalize(_n: BlockNumber) {} /// This will be run when the block is being finalized (before `on_finalize`). - /// Implement to have something happen using the remaining weight. - /// Will not fire if the remaining weight is 0. - /// Return the weight used, the hook will subtract it from current weight used - /// and pass the result to the next `on_idle` hook if it exists. + /// + /// Implement to have something happen using the remaining weight. Will not fire if the + /// remaining weight is 0. + /// + /// Each pallet's `on_idle` is chosen to be the first to execute in a round-robin fashion + /// indexed by the block number. + /// + /// Return the weight used, the caller will use this to calculate the remaining weight and then + /// call the next pallet `on_idle` hook if there is still weight left. fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight { Weight::zero() }