Move WeightCounter to sp-weights (#12603)

* Move WeightCounter to sp_weights

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Rename to WeightMeter and test

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Fix pallet-scheduler for new usage

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Update primitives/weights/src/weight_meter.rs

Co-authored-by: David <dvdplm@gmail.com>

* More tests for can_accrue

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Clippy

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Remove defensive_accrue and fixup consumed_ratio

I dont think there is a good use-case for defensive_accrue
without saturation. Only in tests maybe, will remove for now
until we have a use-case.

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Test

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: David <dvdplm@gmail.com>
Co-authored-by: Gavin Wood <gavin@parity.io>
This commit is contained in:
Oliver Tale-Yazdi
2022-11-11 12:26:47 +01:00
committed by GitHub
parent e04b0c4929
commit bd2166de79
4 changed files with 195 additions and 39 deletions
+4
View File
@@ -26,6 +26,9 @@
#![cfg_attr(not(feature = "std"), no_std)]
extern crate self as sp_weights;
mod weight_meter;
mod weight_v2;
use codec::{CompactAs, Decode, Encode, MaxEncodedLen};
@@ -40,6 +43,7 @@ use sp_arithmetic::{
use sp_core::Get;
use sp_debug_derive::RuntimeDebug;
pub use weight_meter::*;
pub use weight_v2::*;
pub mod constants {