Struct pallet_distance::pallet::Pallet
source · pub struct Pallet<T>(PhantomData<T>);
Expand description
The Pallet
struct, the main type that implements traits and standalone
functions within the pallet.
Tuple Fields§
§0: PhantomData<T>
Implementations§
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn request_distance_evaluation(
origin: OriginFor<T>
) -> DispatchResultWithPostInfo
pub fn request_distance_evaluation( origin: OriginFor<T> ) -> DispatchResultWithPostInfo
Request evaluation of the caller’s identity distance.
This function allows the caller to request an evaluation of their distance. A positive evaluation will lead to claiming or renewing membership, while a negative evaluation will result in slashing for the caller.
sourcepub fn request_distance_evaluation_for(
origin: OriginFor<T>,
target: T::IdtyIndex
) -> DispatchResultWithPostInfo
pub fn request_distance_evaluation_for( origin: OriginFor<T>, target: T::IdtyIndex ) -> DispatchResultWithPostInfo
Request evaluation of a target identity’s distance.
This function allows the caller to request an evaluation of a specific target identity’s distance. This action is only permitted for unvalidated identities.
sourcepub fn update_evaluation(
origin: OriginFor<T>,
computation_result: ComputationResult
) -> DispatchResult
pub fn update_evaluation( origin: OriginFor<T>, computation_result: ComputationResult ) -> DispatchResult
Push an evaluation result to the pool.
This inherent function is called internally by validators to push an evaluation result to the evaluation pool.
sourcepub fn force_update_evaluation(
origin: OriginFor<T>,
evaluator: <T as Config>::AccountId,
computation_result: ComputationResult
) -> DispatchResult
pub fn force_update_evaluation( origin: OriginFor<T>, evaluator: <T as Config>::AccountId, computation_result: ComputationResult ) -> DispatchResult
Force push an evaluation result to the pool.
It is primarily used for testing purposes.
origin
: Must beRoot
.
sourcepub fn force_valid_distance_status(
origin: OriginFor<T>,
identity: <T as Config>::IdtyIndex
) -> DispatchResult
pub fn force_valid_distance_status( origin: OriginFor<T>, identity: <T as Config>::IdtyIndex ) -> DispatchResult
Force set the distance evaluation status of an identity.
It is primarily used for testing purposes.
origin
: Must beRoot
.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcefn mutate_current_pool<R, F: FnOnce(&mut EvaluationPool<<T as Config>::AccountId, <T as Config>::IdtyIndex>) -> R>(
index: u32,
f: F
) -> R
fn mutate_current_pool<R, F: FnOnce(&mut EvaluationPool<<T as Config>::AccountId, <T as Config>::IdtyIndex>) -> R>( index: u32, f: F ) -> R
Mutate the evaluation pool containing:
- when this period begins: the evaluation results to be applied.
- when this period ends: the evaluation requests.
sourcefn mutate_next_pool<R, F: FnOnce(&mut EvaluationPool<<T as Config>::AccountId, <T as Config>::IdtyIndex>) -> R>(
index: u32,
f: F
) -> R
fn mutate_next_pool<R, F: FnOnce(&mut EvaluationPool<<T as Config>::AccountId, <T as Config>::IdtyIndex>) -> R>( index: u32, f: F ) -> R
Mutate the evaluation pool containing the results sent by evaluators for this period.
sourcefn take_current_pool(
index: u32
) -> EvaluationPool<<T as Config>::AccountId, <T as Config>::IdtyIndex>
fn take_current_pool( index: u32 ) -> EvaluationPool<<T as Config>::AccountId, <T as Config>::IdtyIndex>
Take (and leave empty) the evaluation pool containing:
- when this period begins: the evaluation results to be applied.
- when this period ends: the evaluation requests.
sourcefn check_request_distance_evaluation_self(
who: &T::AccountId
) -> Result<<T as Config>::IdtyIndex, DispatchError>
fn check_request_distance_evaluation_self( who: &T::AccountId ) -> Result<<T as Config>::IdtyIndex, DispatchError>
Check if requested distance evaluation is allowed.
sourcefn check_request_distance_evaluation_for(
who: &T::AccountId,
target: <T as Config>::IdtyIndex
) -> Result<(), DispatchError>
fn check_request_distance_evaluation_for( who: &T::AccountId, target: <T as Config>::IdtyIndex ) -> Result<(), DispatchError>
check that targeted request distance evaluation is allowed
fn check_request_distance_evaluation_common( target: <T as Config>::IdtyIndex ) -> Result<(), DispatchError>
sourcefn do_request_distance_evaluation(
who: &T::AccountId,
idty_index: <T as Config>::IdtyIndex
) -> Result<(), DispatchError>
fn do_request_distance_evaluation( who: &T::AccountId, idty_index: <T as Config>::IdtyIndex ) -> Result<(), DispatchError>
Request distance evaluation in the current pool.
sourcefn do_update_evaluation(
evaluator: <T as Config>::AccountId,
computation_result: ComputationResult
) -> DispatchResult
fn do_update_evaluation( evaluator: <T as Config>::AccountId, computation_result: ComputationResult ) -> DispatchResult
Update distance evaluation in the next pool.
sourcepub fn do_valid_distance_status(
idty: <T as Config>::IdtyIndex,
distance: Perbill
)
pub fn do_valid_distance_status( idty: <T as Config>::IdtyIndex, distance: Perbill )
Set the distance status using for an identity.
sourcepub fn do_evaluation(index: u32) -> Weight
pub fn do_evaluation(index: u32) -> Weight
Perform evaluation for a specified pool.
This function executes evaluation logic based on the provided pool index. It retrieves the current evaluation pool for the index, processes each evaluation, and handles the outcomes based on the computed median distances. If a positive evaluation result is obtained, it releases reserved funds and updates the distance status accordingly. For negative or inconclusive results, it slashes funds or releases them, respectively.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn evaluation_pool_0(
) -> EvaluationPool<<T as Config>::AccountId, <T as Config>::IdtyIndex>
pub fn evaluation_pool_0( ) -> EvaluationPool<<T as Config>::AccountId, <T as Config>::IdtyIndex>
An auto-generated getter for EvaluationPool0
.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn evaluation_pool_1(
) -> EvaluationPool<<T as Config>::AccountId, <T as Config>::IdtyIndex>
pub fn evaluation_pool_1( ) -> EvaluationPool<<T as Config>::AccountId, <T as Config>::IdtyIndex>
An auto-generated getter for EvaluationPool1
.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn evaluation_pool_2(
) -> EvaluationPool<<T as Config>::AccountId, <T as Config>::IdtyIndex>
pub fn evaluation_pool_2( ) -> EvaluationPool<<T as Config>::AccountId, <T as Config>::IdtyIndex>
An auto-generated getter for EvaluationPool2
.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn pending_evaluation_request<KArg>(
k: KArg
) -> Option<<T as Config>::AccountId>
pub fn pending_evaluation_request<KArg>( k: KArg ) -> Option<<T as Config>::AccountId>
An auto-generated getter for PendingEvaluationRequest
.
Trait Implementations§
source§impl<T: Config> BeforeAllRuntimeMigrations for Pallet<T>
impl<T: Config> BeforeAllRuntimeMigrations for Pallet<T>
source§fn before_all_runtime_migrations() -> Weight
fn before_all_runtime_migrations() -> Weight
source§impl<T> Benchmarking for Pallet<T>
impl<T> Benchmarking for Pallet<T>
source§impl<T: Config> GetStorageVersion for Pallet<T>
impl<T: Config> GetStorageVersion for Pallet<T>
§type InCodeStorageVersion = StorageVersion
type InCodeStorageVersion = StorageVersion
source§fn in_code_storage_version() -> Self::InCodeStorageVersion
fn in_code_storage_version() -> Self::InCodeStorageVersion
storage_version
attribute, or
[NoStorageVersionSet
] if the attribute is missing.source§fn on_chain_storage_version() -> StorageVersion
fn on_chain_storage_version() -> StorageVersion
§fn current_storage_version() -> Self::InCodeStorageVersion
fn current_storage_version() -> Self::InCodeStorageVersion
in_code_storage_version
and will be removed after March 2024.Self::current_storage_version
] instead. Read moresource§impl<T: Config> Hooks<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> Hooks<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
source§fn on_initialize(block: BlockNumberFor<T>) -> Weight
fn on_initialize(block: BlockNumberFor<T>) -> Weight
source§fn on_finalize(_n: BlockNumberFor<T>)
fn on_finalize(_n: BlockNumberFor<T>)
§fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight
fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight
Hooks::on_finalize
]). Read more§fn on_poll(_n: BlockNumber, _weight: &mut WeightMeter)
fn on_poll(_n: BlockNumber, _weight: &mut WeightMeter)
§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Executive
pallet. Read more§fn offchain_worker(_n: BlockNumber)
fn offchain_worker(_n: BlockNumber)
§fn integrity_test()
fn integrity_test()
source§impl<T: Config> IntegrityTest for Pallet<T>
impl<T: Config> IntegrityTest for Pallet<T>
source§fn integrity_test()
fn integrity_test()
Hooks::integrity_test
].source§impl<T: Config> OffchainWorker<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> OffchainWorker<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
source§fn offchain_worker(n: BlockNumberFor<T>)
fn offchain_worker(n: BlockNumberFor<T>)
source§impl<T: Config> OnFinalize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> OnFinalize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
source§fn on_finalize(n: BlockNumberFor<T>)
fn on_finalize(n: BlockNumberFor<T>)
Hooks::on_finalize
].source§impl<T: Config> OnGenesis for Pallet<T>
impl<T: Config> OnGenesis for Pallet<T>
source§fn on_genesis()
fn on_genesis()
source§impl<T: Config> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
source§impl<T: Config> OnInitialize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> OnInitialize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
source§fn on_initialize(n: BlockNumberFor<T>) -> Weight
fn on_initialize(n: BlockNumberFor<T>) -> Weight
Hooks::on_initialize
].source§impl<T: Config> OnPoll<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> OnPoll<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
source§impl<T: Config> OnRuntimeUpgrade for Pallet<T>
impl<T: Config> OnRuntimeUpgrade for Pallet<T>
source§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Hooks::on_runtime_upgrade
].source§impl<T: Config> PalletInfoAccess for Pallet<T>
impl<T: Config> PalletInfoAccess for Pallet<T>
source§fn module_name() -> &'static str
fn module_name() -> &'static str
source§fn crate_version() -> CrateVersion
fn crate_version() -> CrateVersion
source§impl<T> PartialEq for Pallet<T>
impl<T> PartialEq for Pallet<T>
source§impl<T: Config> ProvideInherent for Pallet<T>
impl<T: Config> ProvideInherent for Pallet<T>
§type Error = InherentError
type Error = InherentError
check_inherent
.source§const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER
const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER
source§fn create_inherent(data: &InherentData) -> Option<Self::Call>
fn create_inherent(data: &InherentData) -> Option<Self::Call>
InherentData
. Read moresource§fn is_inherent(call: &Self::Call) -> bool
fn is_inherent(call: &Self::Call) -> bool
§fn is_inherent_required(
_: &InherentData
) -> Result<Option<Self::Error>, Self::Error>
fn is_inherent_required( _: &InherentData ) -> Result<Option<Self::Error>, Self::Error>
§fn check_inherent(_: &Self::Call, _: &InherentData) -> Result<(), Self::Error>
fn check_inherent(_: &Self::Call, _: &InherentData) -> Result<(), Self::Error>
source§impl<T: Config> WhitelistedStorageKeys for Pallet<T>
impl<T: Config> WhitelistedStorageKeys for Pallet<T>
source§fn whitelisted_storage_keys() -> Vec<TrackedStorageKey>
fn whitelisted_storage_keys() -> Vec<TrackedStorageKey>
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.impl<T> Eq for Pallet<T>
Auto Trait Implementations§
impl<T> Freeze for Pallet<T>
impl<T> RefUnwindSafe for Pallet<T>where
T: RefUnwindSafe,
impl<T> Send for Pallet<T>where
T: Send,
impl<T> Sync for Pallet<T>where
T: Sync,
impl<T> Unpin for Pallet<T>where
T: Unpin,
impl<T> UnwindSafe for Pallet<T>where
T: 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
§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
§fn checked_from<T>(t: T) -> Option<Self>where
Self: TryFrom<T>,
fn checked_from<T>(t: T) -> Option<Self>where
Self: TryFrom<T>,
§fn checked_into<T>(self) -> Option<T>where
Self: TryInto<T>,
fn checked_into<T>(self) -> Option<T>where
Self: TryInto<T>,
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> IsType<T> for T
impl<T> IsType<T> for T
§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T
. Read more§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.§impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
type Error = <U as TryFromKey<T>>::Error
fn try_into_key(self) -> Result<U, <U as TryFromKey<T>>::Error>
§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.