Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Mention on_idle round-robin logic to trait Hooks cargo doc (#13797)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* fmt

---------

Co-authored-by: Bastian Köcher <[email protected]>
  • Loading branch information
gpestana and bkchr committed Apr 20, 2023
1 parent d1e309f commit 5b508e9
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions frame/support/src/traits/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,15 @@ pub trait Hooks<BlockNumber> {
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()
}
Expand Down

0 comments on commit 5b508e9

Please sign in to comment.