mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 07:01:03 +00:00
use safe math (#3249)
This commit is contained in:
@@ -27,9 +27,9 @@ impl<T: Get<Weight>, C: Decode + GetDispatchInfo> WeightBounds<C> for FixedWeigh
|
|||||||
fn shallow(message: &mut Xcm<C>) -> Result<Weight, ()> {
|
fn shallow(message: &mut Xcm<C>) -> Result<Weight, ()> {
|
||||||
Ok(match message {
|
Ok(match message {
|
||||||
Xcm::Transact { call, .. } => {
|
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::WithdrawAsset { effects, .. }
|
||||||
| Xcm::ReserveAssetDeposit { effects, .. }
|
| Xcm::ReserveAssetDeposit { effects, .. }
|
||||||
| Xcm::TeleportAsset { effects, .. }
|
| Xcm::TeleportAsset { effects, .. }
|
||||||
@@ -46,7 +46,7 @@ impl<T: Get<Weight>, C: Decode + GetDispatchInfo> WeightBounds<C> for FixedWeigh
|
|||||||
},
|
},
|
||||||
_ => T::get(),
|
_ => T::get(),
|
||||||
}).sum();
|
}).sum();
|
||||||
T::get() + inner
|
T::get().saturating_add(inner)
|
||||||
}
|
}
|
||||||
_ => T::get(),
|
_ => T::get(),
|
||||||
})
|
})
|
||||||
@@ -63,7 +63,7 @@ impl<T: Get<Weight>, C: Decode + GetDispatchInfo> WeightBounds<C> for FixedWeigh
|
|||||||
match effect {
|
match effect {
|
||||||
Order::BuyExecution { xcm, .. } => {
|
Order::BuyExecution { xcm, .. } => {
|
||||||
for message in xcm.iter_mut() {
|
for message in xcm.iter_mut() {
|
||||||
extra += Self::shallow(message)? + Self::deep(message)?;
|
extra.saturating_accrue(Self::shallow(message)?.saturating_add(Self::deep(message)?));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|||||||
Reference in New Issue
Block a user