Skip to content
Snippets Groups Projects
Commit f59d7fa0 authored by Benjamin Gallois's avatar Benjamin Gallois
Browse files

Remove MembersStorageIter (!220)

* fix #124
parent 54d8caf9
No related branches found
No related tags found
1 merge request!220Remove MembersStorageIter
Pipeline #34977 passed
...@@ -43,7 +43,6 @@ pub mod pallet { ...@@ -43,7 +43,6 @@ pub mod pallet {
use frame_support::traits::{StorageVersion, StoredMap}; use frame_support::traits::{StorageVersion, StoredMap};
use frame_system::pallet_prelude::*; use frame_system::pallet_prelude::*;
use sp_runtime::traits::Convert; use sp_runtime::traits::Convert;
use sp_std::vec::Vec;
pub type BalanceOf<T> = pub type BalanceOf<T> =
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance; <<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
...@@ -69,9 +68,6 @@ pub mod pallet { ...@@ -69,9 +68,6 @@ pub mod pallet {
type MembersCount: Get<BalanceOf<Self>>; type MembersCount: Get<BalanceOf<Self>>;
/// Somethings that must provide the list of accounts ids allowed to create the universal dividend /// Somethings that must provide the list of accounts ids allowed to create the universal dividend
type MembersStorage: frame_support::traits::StoredMap<Self::AccountId, FirstEligibleUd>; type MembersStorage: frame_support::traits::StoredMap<Self::AccountId, FirstEligibleUd>;
/// An iterator over all members
type MembersStorageIter: From<Option<Vec<u8>>>
+ Iterator<Item = (Self::AccountId, FirstEligibleUd)>;
/// Because this pallet emits events, it depends on the runtime's definition of an event. /// Because this pallet emits events, it depends on the runtime's definition of an event.
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>; type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
#[pallet::constant] #[pallet::constant]
......
...@@ -139,23 +139,6 @@ impl frame_support::traits::StoredMap<u32, FirstEligibleUd> for TestMembersStora ...@@ -139,23 +139,6 @@ impl frame_support::traits::StoredMap<u32, FirstEligibleUd> for TestMembersStora
Ok(result) Ok(result)
} }
} }
pub struct TestMembersStorageIter(frame_support::storage::PrefixIterator<(u32, FirstEligibleUd)>);
impl From<Option<Vec<u8>>> for TestMembersStorageIter {
fn from(maybe_key: Option<Vec<u8>>) -> Self {
let mut iter = crate::TestMembers::<Test>::iter();
if let Some(key) = maybe_key {
iter.set_last_raw_key(key);
}
Self(iter)
}
}
impl Iterator for TestMembersStorageIter {
type Item = (u32, FirstEligibleUd);
fn next(&mut self) -> Option<Self::Item> {
self.0.next()
}
}
impl pallet_universal_dividend::Config for Test { impl pallet_universal_dividend::Config for Test {
type MomentIntoBalance = sp_runtime::traits::ConvertInto; type MomentIntoBalance = sp_runtime::traits::ConvertInto;
...@@ -163,7 +146,6 @@ impl pallet_universal_dividend::Config for Test { ...@@ -163,7 +146,6 @@ impl pallet_universal_dividend::Config for Test {
type MaxPastReeval = frame_support::traits::ConstU32<2>; type MaxPastReeval = frame_support::traits::ConstU32<2>;
type MembersCount = MembersCount; type MembersCount = MembersCount;
type MembersStorage = TestMembersStorage; type MembersStorage = TestMembersStorage;
type MembersStorageIter = TestMembersStorageIter;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type SquareMoneyGrowthRate = SquareMoneyGrowthRate; type SquareMoneyGrowthRate = SquareMoneyGrowthRate;
type UdCreationPeriod = UdCreationPeriod; type UdCreationPeriod = UdCreationPeriod;
......
...@@ -439,7 +439,6 @@ macro_rules! pallets_config { ...@@ -439,7 +439,6 @@ macro_rules! pallets_config {
type MaxPastReeval = frame_support::traits::ConstU32<160>; type MaxPastReeval = frame_support::traits::ConstU32<160>;
type MembersCount = MembersCount; type MembersCount = MembersCount;
type MembersStorage = common_runtime::providers::UdMembersStorage<Runtime>; type MembersStorage = common_runtime::providers::UdMembersStorage<Runtime>;
type MembersStorageIter = common_runtime::providers::UdMembersStorageIter<Runtime>;
type SquareMoneyGrowthRate = SquareMoneyGrowthRate; type SquareMoneyGrowthRate = SquareMoneyGrowthRate;
type UdCreationPeriod = UdCreationPeriod; type UdCreationPeriod = UdCreationPeriod;
type UdReevalPeriod = UdReevalPeriod; type UdReevalPeriod = UdReevalPeriod;
......
...@@ -18,8 +18,6 @@ use crate::{entities::IdtyData, AccountId, IdtyIndex}; ...@@ -18,8 +18,6 @@ use crate::{entities::IdtyData, AccountId, IdtyIndex};
use core::marker::PhantomData; use core::marker::PhantomData;
use pallet_universal_dividend::FirstEligibleUd; use pallet_universal_dividend::FirstEligibleUd;
use sp_runtime::DispatchError; use sp_runtime::DispatchError;
use sp_std::boxed::Box;
use sp_std::vec::Vec;
pub struct IdentityAccountIdProvider<Runtime>(PhantomData<Runtime>); pub struct IdentityAccountIdProvider<Runtime>(PhantomData<Runtime>);
...@@ -73,41 +71,6 @@ where ...@@ -73,41 +71,6 @@ where
} }
} }
#[allow(clippy::type_complexity)]
pub struct UdMembersStorageIter<T: pallet_identity::Config>(
Box<dyn Iterator<Item = pallet_identity::IdtyValue<T::BlockNumber, T::AccountId, T::IdtyData>>>,
PhantomData<T>,
);
impl<T: pallet_identity::Config> From<Option<Vec<u8>>> for UdMembersStorageIter<T> {
fn from(maybe_key: Option<Vec<u8>>) -> Self {
let mut iter = pallet_identity::Identities::<T>::iter_values();
if let Some(key) = maybe_key {
iter.set_last_raw_key(key);
}
Self(Box::new(iter), PhantomData)
}
}
impl<T> Iterator for UdMembersStorageIter<T>
where
T: pallet_identity::Config,
T::IdtyData: Into<FirstEligibleUd>,
{
type Item = (T::AccountId, FirstEligibleUd);
fn next(&mut self) -> Option<Self::Item> {
if let Some(pallet_identity::IdtyValue {
owner_key, data, ..
}) = self.0.next()
{
Some((owner_key, data.into()))
} else {
None
}
}
}
pub struct MainWotIsDistanceOk<T>(PhantomData<T>); pub struct MainWotIsDistanceOk<T>(PhantomData<T>);
impl<T> pallet_duniter_wot::traits::IsDistanceOk<<T as pallet_identity::Config>::IdtyIndex> impl<T> pallet_duniter_wot::traits::IsDistanceOk<<T as pallet_identity::Config>::IdtyIndex>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment