Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
Mirrored projects
polkadot
Commits
5161ae5b
Unverified
Commit
5161ae5b
authored
Jun 16, 2021
by
Shawn Tabrizi
Committed by
GitHub
Jun 16, 2021
Browse files
use safe math (#3249)
parent
40d1612b
Pipeline
#142571
canceled with stages
in 25 minutes and 37 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
xcm/xcm-builder/src/weight.rs
View file @
5161ae5b
...
...
@@ -27,9 +27,9 @@ impl<T: Get<Weight>, C: Decode + GetDispatchInfo> WeightBounds<C> for FixedWeigh
fn
shallow
(
message
:
&
mut
Xcm
<
C
>
)
->
Result
<
Weight
,
()
>
{
Ok
(
match
message
{
Xcm
::
Transact
{
call
,
..
}
=>
{
call
.ensure_decoded
()
?
.get_dispatch_info
()
.weight
+
T
::
get
()
call
.ensure_decoded
()
?
.get_dispatch_info
()
.weight
.saturating_add
(
T
::
get
()
)
}
Xcm
::
RelayedFrom
{
ref
mut
message
,
..
}
=>
T
::
get
()
+
Self
::
shallow
(
message
.as_mut
())
?
,
Xcm
::
RelayedFrom
{
ref
mut
message
,
..
}
=>
T
::
get
()
.saturating_add
(
Self
::
shallow
(
message
.as_mut
())
?
)
,
Xcm
::
WithdrawAsset
{
effects
,
..
}
|
Xcm
::
ReserveAssetDeposit
{
effects
,
..
}
|
Xcm
::
TeleportAsset
{
effects
,
..
}
...
...
@@ -46,7 +46,7 @@ impl<T: Get<Weight>, C: Decode + GetDispatchInfo> WeightBounds<C> for FixedWeigh
},
_
=>
T
::
get
(),
})
.sum
();
T
::
get
()
+
inner
T
::
get
()
.saturating_add
(
inner
)
}
_
=>
T
::
get
(),
})
...
...
@@ -63,7 +63,7 @@ impl<T: Get<Weight>, C: Decode + GetDispatchInfo> WeightBounds<C> for FixedWeigh
match
effect
{
Order
::
BuyExecution
{
xcm
,
..
}
=>
{
for
message
in
xcm
.iter_mut
()
{
extra
+=
Self
::
shallow
(
message
)
?
+
Self
::
deep
(
message
)
?
;
extra
.saturating_accrue
(
Self
::
shallow
(
message
)
?
.saturating_add
(
Self
::
deep
(
message
)
?
))
;
}
},
_
=>
{}
...
...
Write
Preview
Supports
Markdown
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!
Cancel
Please
register
or
sign in
to comment