WeightMeter: more consistent naming (#14586)

* Rename WeightMeter functions

* Fixes

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

* Fixup and doc + tests

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

* One more test

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

* Fixup pallets

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

* Use correct function 🤦

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

* Apply suggestions from code review

Co-authored-by: Juan <juangirini@gmail.com>

* Update primitives/weights/src/weight_meter.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* Update primitives/weights/src/weight_meter.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* Update primitives/weights/src/weight_meter.rs

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: Juan <juangirini@gmail.com>
Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
Oliver Tale-Yazdi
2023-07-18 16:38:44 +02:00
committed by GitHub
parent 1dc6610524
commit 892831e55c
8 changed files with 173 additions and 57 deletions
+2 -2
View File
@@ -188,7 +188,7 @@ impl ProcessMessage for RecordingMessageProcessor {
};
let required = Weight::from_parts(weight, weight);
if meter.check_accrue(required) {
if meter.try_consume(required).is_ok() {
let mut m = MessagesProcessed::get();
m.push((message.to_vec(), origin));
MessagesProcessed::set(m);
@@ -245,7 +245,7 @@ impl ProcessMessage for CountingMessageProcessor {
}
let required = Weight::from_parts(1, 1);
if meter.check_accrue(required) {
if meter.try_consume(required).is_ok() {
NumMessagesProcessed::set(NumMessagesProcessed::get() + 1);
Ok(true)
} else {