Skip to content

Commit

Permalink
Add extra docs to on_initialize (paritytech#7552)
Browse files Browse the repository at this point in the history
* Add some extra on_initialize docs.

* Address review comments.
  • Loading branch information
tomusdrw authored and shamb0 committed Nov 21, 2020
1 parent 353fe4e commit a4ff31e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions frame/support/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,7 @@ pub trait ChangeMembers<AccountId: Clone + Ord> {
Self::change_members_sorted(&incoming[..], &outgoing[..], &new_members);
}

/// Compute diff between new and old members; they **must already be sorted**.
/// Compute diff between new and old members; they **must already be sorted**.
///
/// Returns incoming and outgoing members.
fn compute_members_diff(
Expand Down Expand Up @@ -1427,6 +1427,9 @@ pub trait GetCallMetadata {
#[impl_for_tuples(30)]
pub trait OnFinalize<BlockNumber> {
/// The block is being finalized. Implement to have something happen.
///
/// NOTE: This function is called AFTER ALL extrinsics in a block are applied,
/// including inherent extrinsics.
fn on_finalize(_n: BlockNumber) {}
}

Expand All @@ -1438,6 +1441,10 @@ pub trait OnInitialize<BlockNumber> {
/// The block is being initialized. Implement to have something happen.
///
/// Return the non-negotiable weight consumed in the block.
///
/// NOTE: This function is called BEFORE ANY extrinsic in a block is applied,
/// including inherent extrinsics. Hence for instance, if you runtime includes
/// `pallet_timestamp`, the `timestamp` is not yet up to date at this point.
fn on_initialize(_n: BlockNumber) -> crate::weights::Weight { 0 }
}

Expand Down Expand Up @@ -1569,7 +1576,7 @@ pub mod schedule {
/// Reschedule a task. For one-off tasks, this dispatch is guaranteed to succeed
/// only if it is executed *before* the currently scheduled block. For periodic tasks,
/// this dispatch is guaranteed to succeed only before the *initial* execution; for
/// others, use `reschedule_named`.
/// others, use `reschedule_named`.
///
/// Will return an error if the `address` is invalid.
fn reschedule(
Expand Down

0 comments on commit a4ff31e

Please sign in to comment.