This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Weight v1.5 Follow Ups #12155
Merged
paritytech-processbot
merged 23 commits into
master
from
shawntabrizi-weight-v1.5-patches
Sep 1, 2022
Merged
Weight v1.5 Follow Ups #12155
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
8c5610b
update api
shawntabrizi 25fe408
update
shawntabrizi ad09687
remove unused
shawntabrizi 488ed4a
remove `one` api
shawntabrizi b131a52
fix unused
shawntabrizi 6d5c9c1
fmt
shawntabrizi d42dae3
add saturating accrue
shawntabrizi af371ce
remove `Weight::new()`
shawntabrizi 0c4722b
use some macros
shawntabrizi cdc9fae
div makes no sense
shawntabrizi 7607196
Update weight_v2.rs
shawntabrizi 31ceda1
missed some
shawntabrizi 2c300c1
more patch
shawntabrizi 63a10e0
fixes
shawntabrizi 3bdda86
more fixes
shawntabrizi 70e70de
more fix
shawntabrizi a96a022
more fix
shawntabrizi 43fb286
Update frame/support/src/weights/weight_v2.rs
shawntabrizi 720de4c
not needed
shawntabrizi 69e1493
Merge branch 'master' into shawntabrizi-weight-v1.5-patches
shawntabrizi 2e2594b
Merge branch 'master' into shawntabrizi-weight-v1.5-patches
shawntabrizi e7d82fe
fix weight file
shawntabrizi 26c4252
Merge branch 'master' into shawntabrizi-weight-v1.5-patches
shawntabrizi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
add saturating accrue
- Loading branch information
commit d42dae3e3ff8e7cf3a462363f0c93c3032a7aa75
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -128,6 +128,13 @@ impl Weight { | |
| Self { ref_time: self.ref_time.saturating_pow(exp) } | ||
| } | ||
|
|
||
| /// Increment [`Weight`] by `amount` via saturating addition. | ||
| pub fn saturating_accrue(&mut self, amount: Self) { | ||
| let mut o = Self::zero(); | ||
| sp_std::mem::swap(&mut o, self); | ||
| *self = o.saturating_add(amount); | ||
| } | ||
|
|
||
| /// Checked [`Weight`] addition. Computes `self + rhs`, returning `None` if overflow occurred. | ||
| pub const fn checked_add(&self, rhs: &Self) -> Option<Self> { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you use standalone functions instead of implementing
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i do implement the checked trait below (where it was possible), but these are const functions. Saturating implies too many things, and it did not make sense for me to implement all of them |
||
| match self.ref_time.checked_add(rhs.ref_time) { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.