mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 18:41:05 +00:00
Indices maintenance (#1705)
* Migrate the indicies crate to 2018 edition. * Use .cloned() instead of .map(|x| x.clone()) * Update documentation.
This commit is contained in:
committed by
Bastian Köcher
parent
1d0049ee00
commit
7d8ae2df5c
@@ -18,9 +18,10 @@
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use std::fmt;
|
||||
use super::{Member, Decode, Encode, As, Input, Output};
|
||||
use crate::{Member, Decode, Encode, As, Input, Output};
|
||||
|
||||
/// A vetted and verified extrinsic from the external world.
|
||||
/// An indices-aware address, which can be either a direct `AccountId` or
|
||||
/// an index.
|
||||
#[derive(PartialEq, Eq, Clone)]
|
||||
#[cfg_attr(feature = "std", derive(Debug, Hash))]
|
||||
pub enum Address<AccountId, AccountIndex> where
|
||||
|
||||
@@ -14,43 +14,26 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Balances: Handles setting and retrieval of free balance,
|
||||
//! retrieving total balance, reserve and unreserve balance,
|
||||
//! repatriating a reserved balance to a beneficiary account that exists,
|
||||
//! transfering a balance between accounts (when not reserved),
|
||||
//! slashing an account balance, account removal, rewards,
|
||||
//! lookup of an index to reclaim an account (when not balance not reserved),
|
||||
//! increasing total stake.
|
||||
//! An index is a short form of an address. This module handles allocation
|
||||
//! of indices for a newly created accounts.
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
// We need these `extern crate` to be placed here otherwise there will be errors.
|
||||
// TODO: https://github.com/paritytech/substrate/issues/1509
|
||||
#[macro_use]
|
||||
extern crate srml_support as runtime_support;
|
||||
|
||||
extern crate sr_std as rstd;
|
||||
|
||||
#[macro_use]
|
||||
extern crate parity_codec_derive;
|
||||
|
||||
extern crate parity_codec as codec;
|
||||
extern crate sr_primitives as primitives;
|
||||
extern crate srml_system as system;
|
||||
|
||||
#[cfg(test)]
|
||||
#[macro_use]
|
||||
extern crate ref_thread_local;
|
||||
#[cfg(test)]
|
||||
extern crate sr_io as runtime_io;
|
||||
#[cfg(test)]
|
||||
extern crate substrate_primitives;
|
||||
|
||||
use rstd::{prelude::*, result, marker::PhantomData};
|
||||
use codec::{Encode, Decode, Codec, Input, Output};
|
||||
use runtime_support::{StorageValue, StorageMap, Parameter};
|
||||
use primitives::traits::{One, SimpleArithmetic, As, StaticLookup, Member};
|
||||
use address::Address as RawAddress;
|
||||
use system::{IsDeadAccount, OnNewAccount};
|
||||
|
||||
use self::address::Address as RawAddress;
|
||||
|
||||
mod mock;
|
||||
|
||||
pub mod address;
|
||||
@@ -104,7 +87,10 @@ decl_event!(
|
||||
<T as system::Trait>::AccountId,
|
||||
<T as Trait>::AccountIndex
|
||||
{
|
||||
/// A new account was created.
|
||||
/// A new account index was assigned.
|
||||
///
|
||||
/// This event is not triggered when an existing index is reassigned
|
||||
/// to another `AccountId`.
|
||||
NewAccountIndex(AccountId, AccountIndex),
|
||||
}
|
||||
);
|
||||
@@ -138,7 +124,7 @@ impl<T: Trait> Module<T> {
|
||||
let enum_set_size = Self::enum_set_size();
|
||||
let set = Self::enum_set(index / enum_set_size);
|
||||
let i: usize = (index % enum_set_size).as_();
|
||||
set.get(i).map(|x| x.clone())
|
||||
set.get(i).cloned()
|
||||
}
|
||||
|
||||
/// `true` if the account `index` is ready for reclaim.
|
||||
|
||||
@@ -19,13 +19,12 @@
|
||||
#![cfg(test)]
|
||||
|
||||
use std::collections::HashSet;
|
||||
use ref_thread_local::RefThreadLocal;
|
||||
use ref_thread_local::{ref_thread_local, RefThreadLocal};
|
||||
use primitives::BuildStorage;
|
||||
use primitives::testing::{Digest, DigestItem, Header};
|
||||
use substrate_primitives::{H256, Blake2Hasher};
|
||||
use runtime_io;
|
||||
use {GenesisConfig, Module, Trait, system};
|
||||
use super::{IsDeadAccount, OnNewAccount, ResolveHint};
|
||||
use {runtime_io, system};
|
||||
use crate::{GenesisConfig, Module, Trait, IsDeadAccount, OnNewAccount, ResolveHint};
|
||||
|
||||
impl_outer_origin!{
|
||||
pub enum Origin for Runtime {}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#![cfg(test)]
|
||||
|
||||
use super::*;
|
||||
use mock::{Indices, new_test_ext, make_account, kill_account, TestIsDeadAccount};
|
||||
use crate::mock::{Indices, new_test_ext, make_account, kill_account, TestIsDeadAccount};
|
||||
use runtime_io::with_externalities;
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user