pub struct Pallet<T, I = ()>(_);
Expand description

The Pallet struct, the main type that implements traits and standalone functions within the pallet.

Implementations§

source§

impl<T: Config<I>, I: 'static> Pallet<T, I>

source

pub fn rebag( origin: OriginFor<T>, dislocated: <<T as Config>::Lookup as StaticLookup>::Source ) -> DispatchResult

Declare that some dislocated account has, through rewards or penalties, sufficiently changed its score that it should properly fall into a different bag than its current one.

Anyone can call this function about any potentially dislocated account.

Will always update the stored score of dislocated to the correct score, based on ScoreProvider.

If dislocated does not exists, it returns an error.

source

pub fn put_in_front_of( origin: OriginFor<T>, lighter: <<T as Config>::Lookup as StaticLookup>::Source ) -> DispatchResult

Move the caller’s Id directly in front of lighter.

The dispatch origin for this call must be Signed and can only be called by the Id of the account going in front of lighter. Fee is payed by the origin under all circumstances.

Only works if:

  • both nodes are within the same bag,
  • and origin has a greater Score than lighter.
source

pub fn put_in_front_of_other( origin: OriginFor<T>, heavier: <<T as Config>::Lookup as StaticLookup>::Source, lighter: <<T as Config>::Lookup as StaticLookup>::Source ) -> DispatchResult

Same as Pallet::put_in_front_of, but it can be called by anyone.

Fee is paid by the origin under all circumstances.

source§

impl<T: Config<I>, I: 'static> Pallet<T, I>

source§

impl<T: Config<I>, I: 'static> Pallet<T, I>

source

pub fn do_rebag( account: &T::AccountId, new_score: T::Score ) -> Result<Option<(T::Score, T::Score)>, ListError>

Move an account from one bag to another, depositing an event on success.

If the account changed bags, returns Ok(Some((from, to))).

source

pub fn list_bags_get(score: T::Score) -> Option<Bag<T, I>>

Equivalent to ListBags::get, but public. Useful for tests in outside of this crate.

Trait Implementations§

source§

impl<T, I: 'static> Benchmarking for Pallet<T, I>where T: Config + Config<I>,

source§

fn benchmarks(extra: bool) -> Vec<BenchmarkMetadata>

Get the benchmarks available for this pallet. Generally there is one benchmark per extrinsic, so these are sometimes just called “extrinsics”. Read more
source§

fn run_benchmark( extrinsic: &[u8], c: &[(BenchmarkParameter, u32)], whitelist: &[TrackedStorageKey], verify: bool, internal_repeats: u32 ) -> Result<Vec<BenchmarkResult>, BenchmarkError>

Run the benchmarks for this pallet.
source§

impl<T: Config<I>, I: 'static> Callable<T> for Pallet<T, I>

§

type RuntimeCall = Call<T, I>

source§

impl<T, I> Clone for Pallet<T, I>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T, I> Debug for Pallet<T, I>

source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<<Pallet<Runtime, ()> as Callable<Runtime>>::RuntimeCall> for RuntimeCall

source§

fn from(call: CallableCallFor<BagsList, Runtime>) -> Self

Converts to this type from the input type.
source§

impl<T: Config<I>, I: 'static> GetStorageVersion for Pallet<T, I>

§

type CurrentStorageVersion = NoStorageVersionSet

This will be filled out by the pallet macro. Read more
source§

fn current_storage_version() -> Self::CurrentStorageVersion

Returns the current storage version as supported by the pallet.
source§

fn on_chain_storage_version() -> StorageVersion

Returns the on-chain storage version of the pallet as stored in the storage.
source§

impl<T: Config<I>, I: 'static> Hooks<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>

source§

fn integrity_test()

Check the integrity of this pallet’s configuration. Read more
source§

fn try_state(_: BlockNumberFor<T>) -> Result<(), TryRuntimeError>

Execute the sanity checks of this pallet, per block. Read more
source§

fn on_initialize(_n: BlockNumber) -> Weight

Block initialization hook. This is called at the very beginning of block execution. Read more
source§

fn on_finalize(_n: BlockNumber)

Block finalization hook. This is called at the very end of block execution. Read more
source§

fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight

Hook to consume a block’s idle time. This will run when the block is being finalized (before Hooks::on_finalize). Read more
source§

fn on_runtime_upgrade() -> Weight

Hook executed when a code change (aka. a “runtime upgrade”) is detected by FRAME. Read more
source§

fn pre_upgrade() -> Result<Vec<u8, Global>, DispatchError>

Execute some pre-checks prior to a runtime upgrade. Read more
source§

fn post_upgrade(_state: Vec<u8, Global>) -> Result<(), DispatchError>

Execute some post-checks after a runtime upgrade. Read more
source§

fn offchain_worker(_n: BlockNumber)

Implementing this function on a pallet allows you to perform long-running tasks that are dispatched as separate threads, and entirely independent of the main wasm runtime. Read more
source§

impl<T: Config<I>, I: 'static> IntegrityTest for Pallet<T, I>

source§

impl IsSubType<<Pallet<Runtime, ()> as Callable<Runtime>>::RuntimeCall> for RuntimeCall

source§

fn is_sub_type(&self) -> Option<&CallableCallFor<BagsList, Runtime>>

Returns Some(_) if self is an instance of sub type T.
source§

impl<T: Config<I>, I: 'static> OffchainWorker<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>

source§

fn offchain_worker(n: BlockNumberFor<T>)

This function is being called after every block import (when fully synced). Read more
source§

impl<T: Config<I>, I: 'static> OnFinalize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>

source§

impl<T: Config<I>, I: 'static> OnGenesis for Pallet<T, I>

source§

fn on_genesis()

Something that should happen at genesis.
source§

impl<T: Config<I>, I: 'static> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>

source§

fn on_idle(n: BlockNumberFor<T>, remaining_weight: Weight) -> Weight

source§

impl<T: Config<I>, I: 'static> OnInitialize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>

source§

impl<T: Config<I>, I: 'static> OnRuntimeUpgrade for Pallet<T, I>

source§

fn on_runtime_upgrade() -> Weight

source§

fn pre_upgrade() -> Result<Vec<u8>, TryRuntimeError>

source§

fn post_upgrade(state: Vec<u8>) -> Result<(), TryRuntimeError>

source§

fn try_on_runtime_upgrade(checks: bool) -> Result<Weight, DispatchError>

The expected and default behavior of this method is to handle executing pre_upgrade -> on_runtime_upgrade -> post_upgrade hooks for a migration. Read more
source§

impl<T: Config<I>, I: 'static> PalletInfoAccess for Pallet<T, I>

source§

fn index() -> usize

Index of the pallet as configured in the runtime.
source§

fn name() -> &'static str

Name of the pallet as configured in the runtime.
source§

fn module_name() -> &'static str

Name of the Rust module containing the pallet.
source§

fn crate_version() -> CrateVersion

Version of the crate containing the pallet.
source§

impl<T: Config<I>, I: 'static> PalletsInfoAccess for Pallet<T, I>

source§

fn count() -> usize

The number of pallets’ information that this type represents. Read more
source§

fn infos() -> Vec<PalletInfoData>

All of the pallets’ information that this type represents.
source§

impl<T, I> PartialEq<Pallet<T, I>> for Pallet<T, I>

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: Config<I>, I: 'static> ScoreProvider<<T as Config>::AccountId> for Pallet<T, I>

§

type Score = <Pallet<T, I> as SortedListProvider<<T as Config>::AccountId>>::Score

source§

fn score(id: &T::AccountId) -> T::Score

Get the current Score of who.
source§

fn set_score_of(id: &T::AccountId, new_score: T::Score)

For tests, benchmarks and fuzzing, set the score.
source§

impl<T: Config<I>, I: 'static> SortedListProvider<<T as Config>::AccountId> for Pallet<T, I>

§

type Error = ListError

The list’s error type.
§

type Score = <T as Config<I>>::Score

The type used by the list to compare nodes for ordering.
source§

fn iter() -> Box<dyn Iterator<Item = T::AccountId>>

An iterator over the list, which can have take called on it.
source§

fn iter_from( start: &T::AccountId ) -> Result<Box<dyn Iterator<Item = T::AccountId>>, Self::Error>

Returns an iterator over the list, starting right after from the given voter. Read more
source§

fn count() -> u32

The current count of ids in the list.
source§

fn contains(id: &T::AccountId) -> bool

Return true if the list already contains id.
source§

fn on_insert(id: T::AccountId, score: T::Score) -> Result<(), ListError>

Hook for inserting a new id. Read more
source§

fn get_score(id: &T::AccountId) -> Result<T::Score, ListError>

Get the score of id.
source§

fn on_update(id: &T::AccountId, new_score: T::Score) -> Result<(), ListError>

Hook for updating a single id. Read more
source§

fn on_remove(id: &T::AccountId) -> Result<(), ListError>

Hook for removing am id from the list. Read more
source§

fn unsafe_regenerate( all: impl IntoIterator<Item = T::AccountId>, score_of: Box<dyn Fn(&T::AccountId) -> T::Score> ) -> u32

Regenerate this list from scratch. Returns the count of items inserted. Read more
source§

fn try_state() -> Result<(), TryRuntimeError>

Check internal state of the list. Only meant for debugging.
source§

fn unsafe_clear()

Remove all items from the list. Read more
source§

fn score_update_worst_case(who: &T::AccountId, is_increase: bool) -> Self::Score

If who changes by the returned amount they are guaranteed to have a worst case change in their list position.
§

fn on_increase( id: &AccountId, additional: Self::Score ) -> Result<(), Self::Error>

Same as on_update, but incorporate some increased score.
§

fn on_decrease( id: &AccountId, decreased: Self::Score ) -> Result<(), Self::Error>

Same as on_update, but incorporate some decreased score. Read more
source§

impl<T: Config<I>, I: 'static> StorageInfoTrait for Pallet<T, I>

source§

impl<T: Config<I>, I: 'static> TryState<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T, I>

source§

fn try_state( n: BlockNumberFor<T>, _s: TryStateSelect ) -> Result<(), TryRuntimeError>

Execute the state checks.
source§

impl<T: Config<I>, I: 'static> WhitelistedStorageKeys for Pallet<T, I>

source§

fn whitelisted_storage_keys() -> Vec<TrackedStorageKey>

Returns a Vec<TrackedStorageKey> indicating the storage keys that should be whitelisted during benchmarking. This means that those keys will be excluded from the benchmarking performance calculation.
source§

impl<T, I> Eq for Pallet<T, I>

Auto Trait Implementations§

§

impl<T, I> RefUnwindSafe for Pallet<T, I>where I: RefUnwindSafe, T: RefUnwindSafe,

§

impl<T, I> Send for Pallet<T, I>where I: Send, T: Send,

§

impl<T, I> Sync for Pallet<T, I>where I: Sync, T: Sync,

§

impl<T, I> Unpin for Pallet<T, I>where I: Unpin, T: Unpin,

§

impl<T, I> UnwindSafe for Pallet<T, I>where I: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CheckedConversion for T

source§

fn checked_from<T>(t: T) -> Option<Self>where Self: TryFrom<T>,

Convert from a value of T into an equivalent instance of Option<Self>. Read more
source§

fn checked_into<T>(self) -> Option<T>where Self: TryInto<T>,

Consume self to return Some equivalent value of Option<T>. Read more
source§

impl<T> DynClone for Twhere T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IsType<T> for T

source§

fn from_ref(t: &T) -> &T

Cast reference.
source§

fn into_ref(&self) -> &T

Cast reference.
source§

fn from_mut(t: &mut T) -> &mut T

Cast mutable reference.
source§

fn into_mut(&mut self) -> &mut T

Cast mutable reference.
source§

impl<T, Outer> IsWrappedBy<Outer> for Twhere Outer: AsRef<T> + AsMut<T> + From<T>, T: From<Outer>,

source§

fn from_ref(outer: &Outer) -> &T

Get a reference to the inner from the outer.

source§

fn from_mut(outer: &mut Outer) -> &mut T

Get a mutable reference to the inner from the outer.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> SaturatedConversion for T

source§

fn saturated_from<T>(t: T) -> Selfwhere Self: UniqueSaturatedFrom<T>,

Convert from a value of T into an equivalent instance of Self. Read more
source§

fn saturated_into<T>(self) -> Twhere Self: UniqueSaturatedInto<T>,

Consume self to return an equivalent value of T. Read more
§

impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<S, T> UncheckedInto<T> for Swhere T: UncheckedFrom<S>,

source§

fn unchecked_into(self) -> T

The counterpart to unchecked_from.
source§

impl<T, S> UniqueSaturatedInto<T> for Swhere T: Bounded, S: TryInto<T>,

source§

fn unique_saturated_into(self) -> T

Consume self to return an equivalent value of T.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
§

impl<T> JsonSchemaMaybe for T

§

impl<T> MaybeDebug for Twhere T: Debug,

source§

impl<T> MaybeRefUnwindSafe for Twhere T: RefUnwindSafe,

source§

impl<T> Member for Twhere T: Send + Sync + Debug + Eq + PartialEq<T> + Clone + 'static,

source§

impl<T> Scalar for Twhere T: 'static + Clone + PartialEq<T> + Debug,