Struct parachain_staking::pallet::CollatorCandidate
source · pub struct CollatorCandidate<AccountId, Balance, CurrencyId> {
pub id: AccountId,
pub bond: Balance,
pub liquidity_token: CurrencyId,
pub delegators: OrderedSet<AccountId>,
pub top_delegations: Vec<Bond<AccountId, Balance, CurrencyId>>,
pub bottom_delegations: Vec<Bond<AccountId, Balance, CurrencyId>>,
pub total_counted: Balance,
pub total_backing: Balance,
pub request: Option<CandidateBondRequest<Balance>>,
pub state: CollatorStatus,
}
Expand description
Collator candidate state with self bond + delegations
Fields§
§id: AccountId
The account of this collator
bond: Balance
This collator’s self stake.
liquidity_token: CurrencyId
This is the liquidity_token the collator uses
delegators: OrderedSet<AccountId>
Set of all delegator AccountIds (to prevent >1 delegation per AccountId)
top_delegations: Vec<Bond<AccountId, Balance, CurrencyId>>
Top T::MaxDelegatorsPerCollator::get() delegations, ordered greatest to least
bottom_delegations: Vec<Bond<AccountId, Balance, CurrencyId>>
Bottom delegations (unbounded), ordered least to greatest
total_counted: Balance
Sum of top delegations + self.bond
total_backing: Balance
Sum of all delegations + self.bond = (total_counted + uncounted)
request: Option<CandidateBondRequest<Balance>>
Maximum 1 pending request to adjust candidate self bond at any given time
state: CollatorStatus
Current status of the collator
Implementations§
source§impl<A, Balance, CurrencyId> CollatorCandidate<A, Balance, CurrencyId>where
A: Ord + Clone + Debug,
Balance: Default + PartialOrd + CheckedAdd + CheckedSub + Saturating + Ord + Copy,
CurrencyId: Copy,
impl<A, Balance, CurrencyId> CollatorCandidate<A, Balance, CurrencyId>where A: Ord + Clone + Debug, Balance: Default + PartialOrd + CheckedAdd + CheckedSub + Saturating + Ord + Copy, CurrencyId: Copy,
pub fn new(id: A, bond: Balance, liquidity_token: CurrencyId) -> Self
pub fn is_active(&self) -> bool
pub fn is_leaving(&self) -> bool
pub fn can_leave<T: Config>(&self) -> DispatchResult
sourcepub fn schedule_bond_more<T: Config>(
&mut self,
more: Balance,
use_balance_from: Option<BondKind>
) -> Result<u32, DispatchError>where
T::AccountId: From<A>,
BalanceOf<T>: From<Balance>,
CurrencyIdOf<T>: From<CurrencyId>,
pub fn schedule_bond_more<T: Config>( &mut self, more: Balance, use_balance_from: Option<BondKind> ) -> Result<u32, DispatchError>where T::AccountId: From<A>, BalanceOf<T>: From<Balance>, CurrencyIdOf<T>: From<CurrencyId>,
Schedule executable increase of collator candidate self bond Returns the round at which the collator can execute the pending request
sourcepub fn schedule_bond_less<T: Config>(
&mut self,
less: Balance
) -> Result<u32, DispatchError>where
BalanceOf<T>: From<Balance>,
CurrencyIdOf<T>: From<CurrencyId>,
pub fn schedule_bond_less<T: Config>( &mut self, less: Balance ) -> Result<u32, DispatchError>where BalanceOf<T>: From<Balance>, CurrencyIdOf<T>: From<CurrencyId>,
Schedule executable decrease of collator candidate self bond Returns the round at which the collator can execute the pending request
sourcepub fn execute_pending_request<T: Config>(
&mut self,
use_balance_from: Option<BondKind>
) -> Result<Event<T>, DispatchError>where
T::AccountId: From<A>,
BalanceOf<T>: From<Balance>,
CurrencyIdOf<T>: From<CurrencyId>,
pub fn execute_pending_request<T: Config>( &mut self, use_balance_from: Option<BondKind> ) -> Result<Event<T>, DispatchError>where T::AccountId: From<A>, BalanceOf<T>: From<Balance>, CurrencyIdOf<T>: From<CurrencyId>,
Execute pending request to change the collator self bond Returns the event to be emitted
sourcepub fn cancel_pending_request<T: Config>(
&mut self
) -> Result<Event<T>, DispatchError>where
T::AccountId: From<A>,
CandidateBondRequest<BalanceOf<T>>: From<CandidateBondRequest<Balance>>,
pub fn cancel_pending_request<T: Config>( &mut self ) -> Result<Event<T>, DispatchError>where T::AccountId: From<A>, CandidateBondRequest<BalanceOf<T>>: From<CandidateBondRequest<Balance>>,
Cancel pending request to change the collator self bond
sourcepub fn add_top_delegation(&mut self, delegation: Bond<A, Balance, CurrencyId>)
pub fn add_top_delegation(&mut self, delegation: Bond<A, Balance, CurrencyId>)
Infallible sorted insertion caller must verify !self.delegators.contains(delegation.owner) before call
sourcepub fn add_bottom_delegation(
&mut self,
delegation: Bond<A, Balance, CurrencyId>
)
pub fn add_bottom_delegation( &mut self, delegation: Bond<A, Balance, CurrencyId> )
Infallible sorted insertion caller must verify !self.delegators.contains(delegation.owner) before call
sourcepub fn sort_top_delegations(&mut self)
pub fn sort_top_delegations(&mut self)
Sort top delegations from greatest to least
sourcepub fn sort_bottom_delegations(&mut self)
pub fn sort_bottom_delegations(&mut self)
Sort bottom delegations from least to greatest
sourcepub fn add_delegation<T: Config>(
&mut self,
acc: A,
amount: Balance
) -> Result<DelegatorAdded<BalanceOf<T>>, DispatchError>where
BalanceOf<T>: From<Balance>,
pub fn add_delegation<T: Config>( &mut self, acc: A, amount: Balance ) -> Result<DelegatorAdded<BalanceOf<T>>, DispatchError>where BalanceOf<T>: From<Balance>,
Bond account and add delegation. If successful, the return value indicates whether the delegation is top for the candidate.
sourcepub fn rm_delegator<T: Config>(
&mut self,
delegator: A
) -> Result<(bool, Balance), DispatchError>
pub fn rm_delegator<T: Config>( &mut self, delegator: A ) -> Result<(bool, Balance), DispatchError>
Return Ok((if_total_counted_changed, delegation_amount))
sourcepub fn decrease_delegation<T: Config>(
&mut self,
delegator: A,
less: Balance
) -> Result<bool, DispatchError>
pub fn decrease_delegation<T: Config>( &mut self, delegator: A, less: Balance ) -> Result<bool, DispatchError>
Return true if in_top after call
pub fn go_offline(&mut self)
pub fn go_online(&mut self)
pub fn leave<T: Config>(&mut self) -> Result<(u32, u32), DispatchError>
Trait Implementations§
source§impl<AccountId, Balance, CurrencyId> Debug for CollatorCandidate<AccountId, Balance, CurrencyId>where
AccountId: Debug,
Balance: Debug,
CurrencyId: Debug,
impl<AccountId, Balance, CurrencyId> Debug for CollatorCandidate<AccountId, Balance, CurrencyId>where AccountId: Debug, Balance: Debug, CurrencyId: Debug,
source§impl<AccountId, Balance, CurrencyId> Decode for CollatorCandidate<AccountId, Balance, CurrencyId>where
AccountId: Decode,
Balance: Decode,
CurrencyId: Decode,
OrderedSet<AccountId>: Decode,
Vec<Bond<AccountId, Balance, CurrencyId>>: Decode,
Option<CandidateBondRequest<Balance>>: Decode,
impl<AccountId, Balance, CurrencyId> Decode for CollatorCandidate<AccountId, Balance, CurrencyId>where AccountId: Decode, Balance: Decode, CurrencyId: Decode, OrderedSet<AccountId>: Decode, Vec<Bond<AccountId, Balance, CurrencyId>>: Decode, Option<CandidateBondRequest<Balance>>: Decode,
source§fn decode<__CodecInputEdqy: Input>(
__codec_input_edqy: &mut __CodecInputEdqy
) -> Result<Self, Error>
fn decode<__CodecInputEdqy: Input>( __codec_input_edqy: &mut __CodecInputEdqy ) -> Result<Self, Error>
source§fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>
) -> Result<DecodeFinished, Error>where
I: Input,
fn decode_into<I>( input: &mut I, dst: &mut MaybeUninit<Self> ) -> Result<DecodeFinished, Error>where I: Input,
source§impl<AccountId, Balance, CurrencyId> Encode for CollatorCandidate<AccountId, Balance, CurrencyId>where
AccountId: Encode,
Balance: Encode,
CurrencyId: Encode,
OrderedSet<AccountId>: Encode,
Vec<Bond<AccountId, Balance, CurrencyId>>: Encode,
Option<CandidateBondRequest<Balance>>: Encode,
impl<AccountId, Balance, CurrencyId> Encode for CollatorCandidate<AccountId, Balance, CurrencyId>where AccountId: Encode, Balance: Encode, CurrencyId: Encode, OrderedSet<AccountId>: Encode, Vec<Bond<AccountId, Balance, CurrencyId>>: Encode, Option<CandidateBondRequest<Balance>>: Encode,
source§fn size_hint(&self) -> usize
fn size_hint(&self) -> usize
source§fn encode_to<__CodecOutputEdqy: Output + ?Sized>(
&self,
__codec_dest_edqy: &mut __CodecOutputEdqy
)
fn encode_to<__CodecOutputEdqy: Output + ?Sized>( &self, __codec_dest_edqy: &mut __CodecOutputEdqy )
source§fn using_encoded<R, F>(&self, f: F) -> Rwhere
F: FnOnce(&[u8]) -> R,
fn using_encoded<R, F>(&self, f: F) -> Rwhere F: FnOnce(&[u8]) -> R,
source§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
source§impl<A: Clone, Balance, CurrencyId> From<CollatorCandidate<A, Balance, CurrencyId>> for CollatorSnapshot<A, Balance, CurrencyId>
impl<A: Clone, Balance, CurrencyId> From<CollatorCandidate<A, Balance, CurrencyId>> for CollatorSnapshot<A, Balance, CurrencyId>
source§fn from(
other: CollatorCandidate<A, Balance, CurrencyId>
) -> CollatorSnapshot<A, Balance, CurrencyId>
fn from( other: CollatorCandidate<A, Balance, CurrencyId> ) -> CollatorSnapshot<A, Balance, CurrencyId>
source§impl<AccountId, Balance, CurrencyId> TypeInfo for CollatorCandidate<AccountId, Balance, CurrencyId>where
AccountId: TypeInfo + 'static,
Balance: TypeInfo + 'static,
CurrencyId: TypeInfo + 'static,
OrderedSet<AccountId>: TypeInfo + 'static,
Vec<Bond<AccountId, Balance, CurrencyId>>: TypeInfo + 'static,
Option<CandidateBondRequest<Balance>>: TypeInfo + 'static,
impl<AccountId, Balance, CurrencyId> TypeInfo for CollatorCandidate<AccountId, Balance, CurrencyId>where AccountId: TypeInfo + 'static, Balance: TypeInfo + 'static, CurrencyId: TypeInfo + 'static, OrderedSet<AccountId>: TypeInfo + 'static, Vec<Bond<AccountId, Balance, CurrencyId>>: TypeInfo + 'static, Option<CandidateBondRequest<Balance>>: TypeInfo + 'static,
impl<AccountId, Balance, CurrencyId> EncodeLike<CollatorCandidate<AccountId, Balance, CurrencyId>> for CollatorCandidate<AccountId, Balance, CurrencyId>where AccountId: Encode, Balance: Encode, CurrencyId: Encode, OrderedSet<AccountId>: Encode, Vec<Bond<AccountId, Balance, CurrencyId>>: Encode, Option<CandidateBondRequest<Balance>>: Encode,
Auto Trait Implementations§
impl<AccountId, Balance, CurrencyId> RefUnwindSafe for CollatorCandidate<AccountId, Balance, CurrencyId>where AccountId: RefUnwindSafe, Balance: RefUnwindSafe, CurrencyId: RefUnwindSafe,
impl<AccountId, Balance, CurrencyId> Send for CollatorCandidate<AccountId, Balance, CurrencyId>where AccountId: Send, Balance: Send, CurrencyId: Send,
impl<AccountId, Balance, CurrencyId> Sync for CollatorCandidate<AccountId, Balance, CurrencyId>where AccountId: Sync, Balance: Sync, CurrencyId: Sync,
impl<AccountId, Balance, CurrencyId> Unpin for CollatorCandidate<AccountId, Balance, CurrencyId>where AccountId: Unpin, Balance: Unpin, CurrencyId: Unpin,
impl<AccountId, Balance, CurrencyId> UnwindSafe for CollatorCandidate<AccountId, Balance, CurrencyId>where AccountId: UnwindSafe, Balance: UnwindSafe, CurrencyId: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
source§impl<T> DecodeLimit for Twhere
T: Decode,
impl<T> DecodeLimit for Twhere T: Decode,
source§impl<T> FmtForward for T
impl<T> FmtForward for T
source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where Self: Display,
self
to use its Display
implementation when
Debug
-formatted.source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.source§impl<T> Hashable for Twhere
T: Codec,
impl<T> Hashable for Twhere T: Codec,
fn blake2_128(&self) -> [u8; 16]
fn blake2_256(&self) -> [u8; 32]
fn blake2_128_concat(&self) -> Vec<u8, Global> ⓘ
fn twox_128(&self) -> [u8; 16]
fn twox_256(&self) -> [u8; 32]
fn twox_64_concat(&self) -> Vec<u8, Global> ⓘ
fn identity(&self) -> Vec<u8, Global> ⓘ
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for Twhere Outer: AsRef<T> + AsMut<T> + From<T>, T: From<Outer>,
source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere T: ?Sized,
source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere Self: Sized,
source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere Self: Borrow<B>, B: 'a + ?Sized, R: 'a,
source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> Rwhere Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,
source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere Self: AsRef<U>, U: 'a + ?Sized, R: 'a,
self
, then passes self.as_ref()
into the pipe function.source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere Self: AsMut<U>, U: 'a + ?Sized, R: 'a,
self
, then passes self.as_mut()
into the pipe
function.source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere Self: UniqueSaturatedFrom<T>,
source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere Self: UniqueSaturatedInto<T>,
T
. Read moresource§impl<T> Tap for T
impl<T> Tap for T
source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,
Borrow<B>
of a value. Read moresource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,
BorrowMut<B>
of a value. Read moresource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,
AsRef<R>
view of a value. Read moresource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,
AsMut<R>
view of a value. Read moresource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere Self: Deref<Target = T>, T: ?Sized,
Deref::Target
of a value. Read moresource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere Self: DerefMut<Target = T> + Deref, T: ?Sized,
Deref::Target
of a value. Read moresource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,
.tap_borrow()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,
.tap_ref()
only in debug builds, and is erased in release
builds.source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,
.tap_ref_mut()
only in debug builds, and is erased in release
builds.source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere T: UncheckedFrom<S>,
source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.source§impl<T, S> UniqueSaturatedInto<T> for Swhere
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for Swhere T: Bounded, S: TryInto<T>,
source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.