Jelajahi Sumber

runtime: proposals/engine: use dispatchable weight info in `on_initialize`

Using `GetDispatchInfo` get the weight for the executed dispatchables and add
that to the weight of the `on_initialize` function.
conectado 4 tahun lalu
induk
melakukan
0435eb22cd
1 mengubah file dengan 7 tambahan dan 0 penghapusan
  1. 7 0
      runtime-modules/proposals/engine/src/lib.rs

+ 7 - 0
runtime-modules/proposals/engine/src/lib.rs

@@ -352,6 +352,13 @@ decl_module! {
         /// Exports const -  max simultaneous active proposals number.
         const MaxActiveProposalLimit: u32 = T::MaxActiveProposalLimit::get();
 
+        /// Block Initialization. Perform voting period check, vote result tally, approved proposals
+        /// grace period checks, and proposal execution.
+        fn on_initialize() -> Weight {
+            10_000_000 // TODO: adjust weight
+                .saturating_add(Self::process_proposals())
+        }
+
         /// Vote extrinsic. Conditions:  origin must allow votes.
         #[weight = 10_000_000] // TODO: adjust weight
         pub fn vote(