referrerpolicy=no-referrer-when-downgrade

pallet_fast_unstake/
types.rs

1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: Apache-2.0
5
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// 	http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17
18//! Types used in the Fast Unstake pallet.
19
20use crate::Config;
21use codec::{Decode, Encode, MaxEncodedLen};
22use frame_support::{
23	traits::Currency, BoundedVec, CloneNoBound, EqNoBound, PartialEqNoBound, RuntimeDebugNoBound,
24};
25use scale_info::TypeInfo;
26use sp_staking::{EraIndex, StakingInterface};
27
28/// Maximum number of eras that we might check for a single staker.
29///
30/// In effect, it is the bonding duration, coming from [`Config::Staking`], plus one.
31#[derive(scale_info::TypeInfo, codec::Encode, codec::Decode, codec::MaxEncodedLen)]
32#[codec(mel_bound(T: Config))]
33#[scale_info(skip_type_params(T))]
34pub struct MaxChecking<T: Config>(core::marker::PhantomData<T>);
35impl<T: Config> frame_support::traits::Get<u32> for MaxChecking<T> {
36	fn get() -> u32 {
37		T::Staking::bonding_duration() + 1
38	}
39}
40
41#[docify::export]
42pub type BalanceOf<T> =
43	<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
44/// An unstake request.
45///
46/// This is stored in [`crate::Head`] storage item and points to the current unstake request that is
47/// being processed.
48#[derive(
49	Encode,
50	Decode,
51	EqNoBound,
52	PartialEqNoBound,
53	CloneNoBound,
54	TypeInfo,
55	RuntimeDebugNoBound,
56	MaxEncodedLen,
57)]
58#[scale_info(skip_type_params(T))]
59pub struct UnstakeRequest<T: Config> {
60	/// This list of stashes are being processed in this request, and their corresponding deposit.
61	pub stashes: BoundedVec<(T::AccountId, BalanceOf<T>), T::BatchSize>,
62	/// The list of eras for which they have been checked.
63	pub checked: BoundedVec<EraIndex, MaxChecking<T>>,
64}