Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
polkadot-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
parity
Mirrored projects
polkadot-sdk
Commits
a8245e4a
Commit
a8245e4a
authored
3 years ago
by
Alexander Popiak
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
use WEIGHT_PER_SECOND in FixedRateOfFungible (#3611)
* use WEIGHT_PER_SECOND in FixedRateOfFungible * move import
parent
8c3202f0
Branches
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
polkadot/xcm/xcm-builder/src/weight.rs
+2
-4
2 additions, 4 deletions
polkadot/xcm/xcm-builder/src/weight.rs
with
2 additions
and
4 deletions
polkadot/xcm/xcm-builder/src/weight.rs
+
2
−
4
View file @
a8245e4a
...
...
@@ -16,7 +16,7 @@
use
frame_support
::{
traits
::{
tokens
::
currency
::
Currency
as
CurrencyT
,
Get
,
OnUnbalanced
as
OnUnbalancedT
},
weights
::{
GetDispatchInfo
,
Weight
,
WeightToFeePolynomial
},
weights
::{
constants
::
WEIGHT_PER_SECOND
,
GetDispatchInfo
,
Weight
,
WeightToFeePolynomial
},
};
use
parity_scale_codec
::
Decode
;
use
sp_runtime
::
traits
::{
SaturatedConversion
,
Saturating
,
Zero
};
...
...
@@ -131,7 +131,6 @@ impl<T: Get<(MultiLocation, u128)>, R: TakeRevenue> WeightTrader
fn
buy_weight
(
&
mut
self
,
weight
:
Weight
,
payment
:
Assets
)
->
Result
<
Assets
,
Error
>
{
let
(
id
,
units_per_second
)
=
T
::
get
();
use
frame_support
::
weights
::
constants
::
WEIGHT_PER_SECOND
;
let
amount
=
units_per_second
*
(
weight
as
u128
)
/
(
WEIGHT_PER_SECOND
as
u128
);
let
unused
=
payment
.checked_sub
((
id
,
amount
)
.into
())
.map_err
(|
_
|
Error
::
TooExpensive
)
?
;
self
.0
=
self
.0
.saturating_add
(
weight
);
...
...
@@ -177,7 +176,6 @@ impl<T: Get<(AssetId, u128)>, R: TakeRevenue> WeightTrader for FixedRateOfFungib
fn
buy_weight
(
&
mut
self
,
weight
:
Weight
,
payment
:
Assets
)
->
Result
<
Assets
,
Error
>
{
let
(
id
,
units_per_second
)
=
T
::
get
();
use
frame_support
::
weights
::
constants
::
WEIGHT_PER_SECOND
;
let
amount
=
units_per_second
*
(
weight
as
u128
)
/
(
WEIGHT_PER_SECOND
as
u128
);
if
amount
==
0
{
return
Ok
(
payment
)
...
...
@@ -191,7 +189,7 @@ impl<T: Get<(AssetId, u128)>, R: TakeRevenue> WeightTrader for FixedRateOfFungib
fn
refund_weight
(
&
mut
self
,
weight
:
Weight
)
->
Option
<
MultiAsset
>
{
let
(
id
,
units_per_second
)
=
T
::
get
();
let
weight
=
weight
.min
(
self
.0
);
let
amount
=
units_per_second
*
(
weight
as
u128
)
/
1_000_000_000_000
u128
;
let
amount
=
units_per_second
*
(
weight
as
u128
)
/
(
WEIGHT_PER_SECOND
as
u128
)
;
self
.0
-=
weight
;
self
.1
=
self
.1
.saturating_sub
(
amount
);
if
amount
>
0
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment