-
Notifications
You must be signed in to change notification settings - Fork 689
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Renames WeightMeter
constructors for better readability
#1186
Conversation
Self { consumed: Weight::zero(), limit } | ||
} | ||
|
||
/// Creates [`Self`] with the maximal possible limit for the consumable weight. | ||
pub fn max_limit() -> Self { | ||
Self::from_limit(Weight::MAX) | ||
pub fn new() -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the old one was more expressive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comes after a discussion with @gavofyork around the readability of this piece of code:
let meter = WeightMeter::max_limit();
meter.consume(some_weight);
It reads as though the meter starts from the limit and should saturate with the further consume
call. Going through the impl makes it clear that it still starts from 0.
Since the limit to max is implied with a meter, we should not need to specify it explicitly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe with_max_limit
? I mean your example is understandable, but new
is still not really expressive to what the limit will be. (I will also not block on this, just some thought)
Self { consumed: Weight::zero(), limit } | ||
} | ||
|
||
/// Creates [`Self`] with the maximal possible limit for the consumable weight. | ||
pub fn max_limit() -> Self { | ||
Self::from_limit(Weight::MAX) | ||
pub fn new() -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe with_max_limit
? I mean your example is understandable, but new
is still not really expressive to what the limit will be. (I will also not block on this, just some thought)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(approve to unblock the merge)
* master: (25 commits) fix typos (#1339) Use bandersnatch-vrfs with locked dependencies ref (#1342) Bump bs58 from 0.4.0 to 0.5.0 (#1293) Contracts: `seal0::balance` should return the free balance (#1254) Logs: add extra debug log for negative rep changes (#1205) Added short-benchmarks for cumulus (#1183) [xcm-emulator] Improve hygiene and clean up (#1301) Bump the known_good_semver group with 1 update (#1347) Renames API (#1186) Rename `polkadot-parachain` to `polkadot-parachain-primitives` (#1334) Add README to project root (#1253) Add environmental variable to track decoded instructions (#1320) Fix polkadot-node-core-pvf-prepare-worker build with jemalloc (#1315) Sassafras primitives (#1249) Restructure `dispatch` macro related exports (#1162) backing: move the min votes threshold to the runtime (#1200) Bump zstd from 0.11.2+zstd.1.5.2 to 0.12.4 (#1326) Remove `substrate_test_utils::test` (#1321) remove disable-runtime-api (#1328) [ci] add more jobs for pipeline cancel, cleanup (#1314) ...
Co-authored-by: Javier Viola <javier@parity.io>
Co-authored-by: Javier Viola <javier@parity.io>
* change const value visable * Add docs * Update docs * Update docs 2 * Fix ci * Fix spell check
* change const value visable * Add docs * Update docs * Update docs 2 * Fix ci * Fix spell check
* change const value visable * Add docs * Update docs * Update docs 2 * Fix ci * Fix spell check
* change const value visable * Add docs * Update docs * Update docs 2 * Fix ci * Fix spell check
* change const value visable * Add docs * Update docs * Update docs 2 * Fix ci * Fix spell check
* change const value visable * Add docs * Update docs * Update docs 2 * Fix ci * Fix spell check
* change const value visable * Add docs * Update docs * Update docs 2 * Fix ci * Fix spell check
* change const value visable * Add docs * Update docs * Update docs 2 * Fix ci * Fix spell check
* change const value visable * Add docs * Update docs * Update docs 2 * Fix ci * Fix spell check
* change const value visable * Add docs * Update docs * Update docs 2 * Fix ci * Fix spell check
* change const value visable * Add docs * Update docs * Update docs 2 * Fix ci * Fix spell check
* change const value visable * Add docs * Update docs * Update docs 2 * Fix ci * Fix spell check
* change const value visable * Add docs * Update docs * Update docs 2 * Fix ci * Fix spell check
As discussed in the Elements chat, this PR adds the following changes:
WeightMeter::max_limit()
toWeightMeter::new()
as the maximum weight limit is impliedWeightMeter::from_limit()
toWeightMeter::with_limit()