Weight annotation for block hooks. (#4058)

* Initial version that works with proper tests.

* get rid of todos and grumbles and such.

* Cleanup and fix line-width

* fix test runtime test
This commit is contained in:
Kian Paimani
2019-11-12 14:42:38 +01:00
committed by Gavin Wood
parent ab1b98fee5
commit efedac734d
10 changed files with 339 additions and 15 deletions
+6 -1
View File
@@ -498,13 +498,18 @@ decl_module! {
<Dummy<T>>::put(new_value);
}
// The signature could also look like: `fn on_initialize()`
// The signature could also look like: `fn on_initialize()`.
// This function could also very well have a weight annotation, similar to any other. The
// only difference being that if it is not annotated, the default is
// `SimpleDispatchInfo::zero()`, which resolves into no weight.
#[weight = SimpleDispatchInfo::FixedNormal(1000)]
fn on_initialize(_n: T::BlockNumber) {
// Anything that needs to be done at the start of the block.
// We don't do anything here.
}
// The signature could also look like: `fn on_finalize()`
#[weight = SimpleDispatchInfo::FixedNormal(2000)]
fn on_finalize(_n: T::BlockNumber) {
// Anything that needs to be done at the end of the block.
// We just kill our dummy storage item.