This commit is contained in:
Chevdor
2023-09-06 10:12:55 +02:00
committed by GitHub
parent 51dcc9fbc8
commit 7986b12624
3 changed files with 7 additions and 14 deletions
+3 -2
View File
@@ -34,13 +34,13 @@ use crate::v2::{
WildMultiAsset as OldWildMultiAsset, WildMultiAsset as OldWildMultiAsset,
}; };
use alloc::{vec, vec::Vec}; use alloc::{vec, vec::Vec};
use bounded_collections::{BoundedVec, ConstU32};
use core::{ use core::{
cmp::Ordering, cmp::Ordering,
convert::{TryFrom, TryInto}, convert::{TryFrom, TryInto},
}; };
use parity_scale_codec::{self as codec, Decode, Encode, MaxEncodedLen}; use parity_scale_codec::{self as codec, Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo; use scale_info::TypeInfo;
use bounded_collections::{BoundedVec, ConstU32};
/// A general identifier for an instance of a non-fungible asset class. /// A general identifier for an instance of a non-fungible asset class.
#[derive( #[derive(
@@ -518,7 +518,8 @@ impl MaxEncodedLen for MultiAssets {
impl Decode for MultiAssets { impl Decode for MultiAssets {
fn decode<I: codec::Input>(input: &mut I) -> Result<Self, codec::Error> { fn decode<I: codec::Input>(input: &mut I) -> Result<Self, codec::Error> {
let bounded_instructions = BoundedVec::<MultiAsset, ConstU32<{ MAX_ITEMS_IN_MULTIASSETS as u32 }>>::decode(input)?; let bounded_instructions =
BoundedVec::<MultiAsset, ConstU32<{ MAX_ITEMS_IN_MULTIASSETS as u32 }>>::decode(input)?;
Self::from_sorted_and_deduplicated(bounded_instructions.into_inner()) Self::from_sorted_and_deduplicated(bounded_instructions.into_inner())
.map_err(|()| "Out of order".into()) .map_err(|()| "Out of order".into())
} }
@@ -333,12 +333,8 @@ impl<T: Config> Pallet<T> {
region.begin = r + 1; region.begin = r + 1;
contribution.length.saturating_dec(); contribution.length.saturating_dec();
let Some(mut pool_record) = InstaPoolHistory::<T>::get(r) else { let Some(mut pool_record) = InstaPoolHistory::<T>::get(r) else { continue };
continue let Some(total_payout) = pool_record.maybe_payout else { break };
};
let Some(total_payout) = pool_record.maybe_payout else {
break
};
let p = total_payout let p = total_payout
.saturating_mul(contributed_parts.into()) .saturating_mul(contributed_parts.into())
.checked_div(&pool_record.private_contributions.into()) .checked_div(&pool_record.private_contributions.into())
+2 -6
View File
@@ -95,9 +95,7 @@ impl<T: Config> Pallet<T> {
} }
pub(crate) fn process_revenue() -> bool { pub(crate) fn process_revenue() -> bool {
let Some((until, amount)) = T::Coretime::check_notify_revenue_info() else { let Some((until, amount)) = T::Coretime::check_notify_revenue_info() else { return false };
return false
};
let when: Timeslice = let when: Timeslice =
(until / T::TimeslicePeriod::get()).saturating_sub(One::one()).saturated_into(); (until / T::TimeslicePeriod::get()).saturating_sub(One::one()).saturated_into();
let mut revenue = T::ConvertBalance::convert_back(amount); let mut revenue = T::ConvertBalance::convert_back(amount);
@@ -289,9 +287,7 @@ impl<T: Config> Pallet<T> {
rc_begin: RelayBlockNumberOf<T>, rc_begin: RelayBlockNumberOf<T>,
core: CoreIndex, core: CoreIndex,
) { ) {
let Some(workplan) = Workplan::<T>::take((timeslice, core)) else { let Some(workplan) = Workplan::<T>::take((timeslice, core)) else { return };
return
};
let workload = Workload::<T>::get(core); let workload = Workload::<T>::get(core);
let parts_used = workplan.iter().map(|i| i.mask).fold(CoreMask::void(), |a, i| a | i); let parts_used = workplan.iter().map(|i| i.mask).fold(CoreMask::void(), |a, i| a | i);
let mut workplan = workplan.into_inner(); let mut workplan = workplan.into_inner();