pub struct Pallet<T>(PhantomData<T>);Expand description
Tuple Fields§
§0: PhantomData<T>Implementations§
Source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
Sourcepub fn enlist(
origin: OriginFor<T>,
collateral: AuthorAsset<T>,
fortitude: FortitudeWrapper,
) -> DispatchResult
pub fn enlist( origin: OriginFor<T>, collateral: AuthorAsset<T>, fortitude: FortitudeWrapper, ) -> DispatchResult
Enlist the caller as an author by locking the required collateral.
Establishes the caller as an author by placing collateral under the author role commitment.
§Requirements
- Provided collateral must be at least
MinCollateral. - Fails if the caller is already enrolled as an author.
§Behavior
- Locks the required collateral and associates it with the author role.
- Ensures at least the minimum collateral is maintained.
§Execution Controls
fortitudedefines how the collateral is sourced:FortitudeWrapper::Force: Uses the caller’s liquid balance to place the collateral.FortitudeWrapper::Polite: Uses funds already deposited into the commitment reserve (ifConfig::CommitmentAdapter==pallet_commitment).
Emits: Event::AuthorEnlisted
Sourcepub fn back(
origin: OriginFor<T>,
via: FundingTarget<T>,
value: AuthorAsset<T>,
fortitude: FortitudeWrapper,
precision: PrecisionWrapper,
) -> DispatchResult
pub fn back( origin: OriginFor<T>, via: FundingTarget<T>, value: AuthorAsset<T>, fortitude: FortitudeWrapper, precision: PrecisionWrapper, ) -> DispatchResult
Provide economic backing support to an author using a supported funding model.
This extrinsic allows the caller to economically support an author by
locking assets under the FreezeReason::AuthorFunding commitment domain.
Funding directly affects an author’s eligibility, exposure, and election weight.
§Funding Models
- Direct: Funds are committed explicitly to a single author.
- Index: Route funds through an index resolving to multiple author digests.
- Pool: Commit funds to a managed pool of authors with commission-based withdrawals.
§Guarantees
- Funds are fully locked and cannot be double-used elsewhere.
- Author collateral is never mixed with external funding.
MinFundandMaxExposureare strictly enforced.- Local minimum and maximum limits enforced by authors and underlying systems are considered.
- Funding is rejected if the resolved author or digest is invalid.
§Execution Controls
precisiondefines how strictly the requested amount must be satisfied:- [
Precision::Exact]: Requires full amount commitment. - [
Precision::BestEffort]: Allows partial fulfillment where supported.
- [
forcedefines how funds are sourced:- [
Fortitude::Force]: Uses the caller’s liquid balance, enforcing the commitment directly. - [
Fortitude::Polite]: Uses funds already deposited in the commitment reserve (ifConfig::CommitmentAdapter==pallet_commitment).
- [
Emits via internal hook:
- Event::AuthorFunded if direct author backing
- Event::IndexFunded multiple authors via an index
- Event::PoolFunded multiple authors via a managed pool
Sourcepub fn refill(
origin: OriginFor<T>,
collateral: AuthorAsset<T>,
fortitude: FortitudeWrapper,
) -> DispatchResult
pub fn refill( origin: OriginFor<T>, collateral: AuthorAsset<T>, fortitude: FortitudeWrapper, ) -> DispatchResult
Increase the caller’s collateral by locking additional assets.
Adds to the existing collateral, strengthening the author’s position
and ensuring compliance with evolving system requirements such
as MinCollateral.
§Behavior
- Collateral is added on top of existing locked collateral.
§Execution Controls
fortitudedefines how the collateral is sourced:FortitudeWrapper::Force: Uses the caller’s liquid balance to place the additional collateral.FortitudeWrapper::Polite: Uses funds already deposited into the commitment reserve (ifConfig::CommitmentAdapter==pallet_commitment).
Sourcepub fn confirm(origin: OriginFor<T>) -> DispatchResult
pub fn confirm(origin: OriginFor<T>) -> DispatchResult
Confirm the caller as an active author after completing probation.
Transitions the author from probation to active status once all probation conditions are satisfied.
§Requirements
- Caller must be under probation.
- Probation conditions must be fulfilled.
§Notes
- Authors are responsible for completing their probation requirements.
- Activation enables full participation in author duties.
Emits: Event::AuthorStatus via internal hook
Sourcepub fn exit(origin: OriginFor<T>, from: FundingTarget<T>) -> DispatchResult
pub fn exit(origin: OriginFor<T>, from: FundingTarget<T>) -> DispatchResult
Exit an existing backing position towards an author.
Releases the caller’s committed funds (including any applicable rewards or penalties) from a direct, index, or pool-based backing, once the position is eligible for exit.
§Behavior
- Exits only the caller’s backing position.
- Author collateral remains unaffected.
- Other backers’ commitments remain intact.
§Validation
- Ensures the backing position exists and is withdrawable.
- Resolves the target author from index or pool digests.
Emits:
Event::AuthorDrawnfor direct backingEvent::IndexDrawnfor index-based backingEvent::PoolDrawnfor pool-based backing
Sourcepub fn demit(origin: OriginFor<T>) -> DispatchResult
pub fn demit(origin: OriginFor<T>) -> DispatchResult
Resign from the author role and exit active participation.
Releases the caller’s collateral while retaining any external backing relationships until funders explicitly exit their positions.
§Behavior
- Removes the caller from active author participation.
- Releases all locked collateral back to the caller.
- External funders/backers must withdraw separately via
Pallet::exit. - The author’s digest is reaped only if no active backing remains.
Emits: Event::AuthorResigned
Sourcepub fn create_index(
origin: OriginFor<T>,
entries: Vec<(Author<T>, Shares<T>)>,
) -> DispatchResult
pub fn create_index( origin: OriginFor<T>, entries: Vec<(Author<T>, Shares<T>)>, ) -> DispatchResult
Create a new funding index over a set of authors.
An index represents a weighted collection of author commitment digests, enabling aggregated funding and proportional exposure.
- Index entries resolve exclusively to author collateral digests.
- Share weights are deterministic and auditable.
- The caller becomes the index owner.
Emits: Event::IndexCreated via deposit event
Sourcepub fn create_pool(
origin: OriginFor<T>,
index: IndexDigest<T>,
commission: Commission<T>,
) -> DispatchResult
pub fn create_pool( origin: OriginFor<T>, index: IndexDigest<T>, commission: Commission<T>, ) -> DispatchResult
Create a new funding pool backed by an existing index.
Pools enable managed aggregation of funds with an explicit commission applied to rewards earned via the underlying index.
- Pool configuration is uniquely identified by its digest.
- Commission is fixed at creation time, changing commission after creates a new pool with same slots and updated commission.
- The caller becomes the initial pool manager.
Emits: Event::PoolCreated via deposit event
Sourcepub fn transfer_pool(
origin: OriginFor<T>,
pool: PoolDigest<T>,
to: T::AccountId,
) -> DispatchResult
pub fn transfer_pool( origin: OriginFor<T>, pool: PoolDigest<T>, to: T::AccountId, ) -> DispatchResult
Transfer management ownership of a funding pool.
Updates the pool manager without affecting custody of funds. The pool remains non-custodial, and all underlying funds, slots, and backing relationships remain unchanged.
§Requirements
- Callable only by the current pool manager.
§Behavior
- Transfers only management control.
- Does not transfer ownership of any pooled funds.
Emits: Event::PoolManager
Sourcepub fn update_commission(
origin: OriginFor<T>,
index: IndexDigest<T>,
commission: Commission<T>,
) -> DispatchResult
pub fn update_commission( origin: OriginFor<T>, index: IndexDigest<T>, commission: Commission<T>, ) -> DispatchResult
Update the commission for a funding pool by creating a new pool instance.
This operation does not mutate the existing pool. Instead, it creates a new pool derived from the given index with the updated commission, assigning the caller as the new pool manager.
§Behavior
- A new pool is created with the specified commission.
- The caller becomes the manager of the new pool.
- The new pool starts with no funds or backing.
- The original pool remains unchanged.
§Notes
- Pools are non-custodial, and funds are not transferred during this operation.
- This effectively creates a fresh pool configuration with updated parameters.
Emits: Event::PoolCreated
Derive a new index with updated share weight for a specific entry.
This operation does not mutate the existing index. Instead, it creates
a new index configuration where the specified entry is assigned the
given shares, while all other entries remain unchanged.
§Behavior
- Produces a new index digest reflecting the updated share distribution.
- The original index remains immutable and unchanged.
§Notes
- Indexes are immutable once created.
- Any modification to entry shares results in a new index instance.
Emits: Event::IndexCreated
Update the share weight of a slot within an existing pool.
Modifies the share allocation of the specified slot in the given pool
without altering the pool’s identity or existing commitments.
§Requirements
- Caller must be the current pool manager.
- The specified pool and slot must be valid.
§Behavior
- Updates the slot’s share weight in place.
- Preserves all existing funds, commitments, and pool configuration.
§Notes
- Unlike indexes, pools are mutable and support in-place updates.
Emits: Event::PoolSlotShare
Sourcepub fn force_genesis_config(
origin: OriginFor<T>,
field: ForceGenesisConfig<T>,
) -> DispatchResult
pub fn force_genesis_config( origin: OriginFor<T>, field: ForceGenesisConfig<T>, ) -> DispatchResult
Force-update a selected genesis configuration parameter.
Origin: Root only.
This extrinsic allows privileged modification of runtime parameters that were originally defined at genesis.
ProbationPeriod- Updates the number of blocks authors must remain in probation.ReduceProbationBy- Updates how much probation is reduced on good behavior.IncreaseProbationBy- Updates how much probation is increased on misbehavior.RewardsBuffer- Updates the delay (in blocks) before rewards are finalized.PenaltiesBuffer- Updates the delay (in blocks) before penalties are enforced.MaxElected- Updates the maximum number of authors that can be elected.MinElected- Updates the minimum number of authors required for a valid election.EnforceMaxElected- Toggles strict enforcement of theMaxElectedlimit.MinFund- Updates the minimum funding required per backing operation.MaxExposure- Updates the maximum allowed exposure per funding operation.MinCollateral- Updates the minimum collateral required for authors.
The call enforces consistency constraints where applicable:
- Values that must be non-zero will fail with
Error::NonZeroConfigRequired. - Fails with
Error::MinGreaterThanMaxif:MinElected > MaxElected, orMinFund > MaxExposure, orMaxElected < MinElected, orMaxExposure < MinFund.
This call directly overwrites storage and emits an event containing the updated configuration variant.
Source§impl<T: Config> Pallet<T>
Public read-only functions for inspecting author collateral and funding state.
impl<T: Config> Pallet<T>
Public read-only functions for inspecting author collateral and funding state.
This interface exposes non-mutating functions that allow external consumers (e.g. off-chain clients, RPC layers, and other pallets) to inspect the economic state of authors and funding relationships.
Sourcepub fn fetch_collateral(who: Author<T>) -> Result<AuthorAsset<T>, DispatchError>
pub fn fetch_collateral(who: Author<T>) -> Result<AuthorAsset<T>, DispatchError>
Return the total locked collateral of an author.
whomust be an enrolled author.
Sourcepub fn inspect_fund(
caller: T::AccountId,
from: FundingTarget<T>,
) -> Result<AuthorAsset<T>, DispatchError>
pub fn inspect_fund( caller: T::AccountId, from: FundingTarget<T>, ) -> Result<AuthorAsset<T>, DispatchError>
Fetch the caller’s total committed funding under a specific funding model.
- The caller must have an active commitment under the specified target.
- The provided digest must match the caller’s active commitment.
Fetch the caller’s committed funding towards a specific author.
- The caller must have an active funding relationship with the author under the specified funding target.
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: Config> CompensateRoles<<T as Config>::AccountId> for Pallet<T>
Implements the CompensateRoles trait for the Author subsystem
impl<T: Config> CompensateRoles<<T as Config>::AccountId> for Pallet<T>
Implements the CompensateRoles trait for the Author subsystem
Defines how authors can be rewarded/slashed along with its backers within the runtime.
Source§type Ratio = Perbill
type Ratio = Perbill
The penalty ratio type.
Uses [Perbill], a fixed-point representation
with 1 billion precision.
§Example
Perbill::from_percent(5)-> 5% penaltyPerbill::from_parts(500_000_000)-> 50% penalty
Source§fn has_reward(who: &Author<T>) -> DispatchResult
fn has_reward(who: &Author<T>) -> DispatchResult
Checks whether the given Author currently has any pending rewards.
- This function only performs a read check - it does not mutate state.
- The lookup range ensures that pending rewards are checked from the next block onward, accounting for rewards that may already be queued but not yet enforced.
DispatchError otherwise.
Source§fn has_penalty(who: &Author<T>) -> DispatchResult
fn has_penalty(who: &Author<T>) -> DispatchResult
Checks whether the given Author currently has any pending penalties.
- This function only performs a read check - it does not mutate state.
- The lookup range ensures that pending penalties are checked from the next block onward, accounting for penalries that may already be queued but not yet enforced.
DispatchError otherwise.
Source§fn get_rewards_of(
who: &Author<T>,
) -> Result<Vec<(Self::TimeStamp, Self::Asset)>, DispatchError>
fn get_rewards_of( who: &Author<T>, ) -> Result<Vec<(Self::TimeStamp, Self::Asset)>, DispatchError>
Retrieves all pending rewards for a given author.
Rewards are finalized over time via periodic enforcement, so the current block is skipped since it would have been finalized
§Returns
Ok(Vec<(TimeStamp, Asset)>)- a list of(block_number, reward_value)tuples for each reward found.Err(DispatchError)- otherwise.
Source§fn get_penalties_of(
who: &Author<T>,
) -> Result<Vec<(Self::TimeStamp, Self::Ratio)>, DispatchError>
fn get_penalties_of( who: &Author<T>, ) -> Result<Vec<(Self::TimeStamp, Self::Ratio)>, DispatchError>
Retrieves all pending penalities for a given author.
Penalties are finalized over time via periodic enforcement, so the current block is skipped since it would have been finalized
§Returns
Ok(Vec<(TimeStamp, Ratio)>)- a list of(block_number, factor)tuples for each penalty found.Err(DispatchError)- otherwise.
Source§fn get_hold(who: &Author<T>) -> Result<Self::Asset, DispatchError>
fn get_hold(who: &Author<T>) -> Result<Self::Asset, DispatchError>
Retrieves the current hold amount for the specified Author.
- This function is read-only and does not modify any runtime state.
- The returned hold includes all live reserved assets for the author: funding, collateral, and enforced rewards/penalties.
DispatchError otherwise
Source§fn get_rewards_on(
time_stamp: Self::TimeStamp,
) -> Result<Vec<(Author<T>, Self::Asset)>, DispatchError>
fn get_rewards_on( time_stamp: Self::TimeStamp, ) -> Result<Vec<(Author<T>, Self::Asset)>, DispatchError>
Retrieves all pending rewards for a specific timestamp across all authors.
This function performs a reverse lookup of rewards scheduled for enforcement
at the given time_stamp.
Rewards at or before the current finalized block cannot be queried, as they are already settled and no longer represent pending obligations.
§Returns
Ok(Vec<(Author<T>, Asset)>)- a list of(author, reward_value)tuples representing pending rewards for the specified timestamp.Err(DispatchError)otherwise.
Source§fn get_penalties_on(
time_stamp: Self::TimeStamp,
) -> Result<Vec<(Author<T>, Self::Ratio)>, DispatchError>
fn get_penalties_on( time_stamp: Self::TimeStamp, ) -> Result<Vec<(Author<T>, Self::Ratio)>, DispatchError>
Retrieves all pending penalties for a specific timestamp across all authors.
This function performs a reverse lookup of penalties scheduled for enforcement
at the given time_stamp.
Penalties at or before the current finalized block cannot be queried, as they are already settled and no longer represent pending obligations.
§Returns
Ok(Vec<(Author<T>, Ratio)>)- a list of(author, factor)tuples representing pending penalties for the specified timestamp.Err(DispatchError)otherwise.
Source§fn set_hold(
who: &Author<T>,
value: Self::Asset,
precision: Precision,
force: Fortitude,
) -> DispatchResult
fn set_hold( who: &Author<T>, value: Self::Asset, precision: Precision, force: Fortitude, ) -> DispatchResult
Updates the total hold amount of an author by proportionally redistributing the specified value across all of its components.
- A hold represents an aggregated value of all live reserved assets for the author: funding, collateral, and enforced rewards/penalties.
This function recalculates and updates these underlying components based on the new total hold value provided.
§Returns
Ok(())- if the total hold was successfully recalculated and updated.Err(DispatchError)- otherwise.
Source§fn penalize(
who: &Author<T>,
factor: Self::Ratio,
) -> Result<Self::TimeStamp, DispatchError>
fn penalize( who: &Author<T>, factor: Self::Ratio, ) -> Result<Self::TimeStamp, DispatchError>
Applies a penalty to a given author, scheduled for enforcement at a future block.
A penalty represents a negative adjustment to the author’s hold.
This function registers a proportional penalty (as a [PerThing] factor)
against all of author’s commitments.
Each penalty is deferred for a specified buffer period to allow orderly finalization and to ensure temporal separation of distinct penalty events.
Applies risk to the author’s permanence before applying the penalty.
Additionally tries to revoke permanence for permenant authors if possible.
§Returns
Ok(TimeStamp)- the block number at which the penalty is scheduled to finalize.Err(DispatchError)- otherwise.
Source§fn forgive(
who: &Author<T>,
from: Self::TimeStamp,
) -> Result<Self::Ratio, DispatchError>
fn forgive( who: &Author<T>, from: Self::TimeStamp, ) -> Result<Self::Ratio, DispatchError>
Removes a pending penalty for a given author, effectively forgiving it at a particular timestamp.
It allows the system to revoke a scheduled penalty that has not yet been finalized,
identified by the specific timestamp (from) at which the penalty was originally set
for enforcement.
- Forgiveness cannot apply to penalties at or before the finalized block height.
- Author permanence is re-secured upon successful forgiveness.
§Returns
Ok(Ratio)- the penalty factor that was successfully forgiven.Err(DispatchError)- otherwise
Source§fn reward(
who: &Author<T>,
value: Self::Asset,
_precision: Precision,
) -> Result<Self::TimeStamp, DispatchError>
fn reward( who: &Author<T>, value: Self::Asset, _precision: Precision, ) -> Result<Self::TimeStamp, DispatchError>
Schedules a reward for a given author at a future block.
A reward represents a positive adjustment to the author’s hold.
Each reward is deferred for a specified buffer period to allow orderly finalization and to ensure temporal separation of distinct penalty events.
Ensures the author’s permanence is secured before applying the reward.
§Returns
Ok(TimeStamp)- the block number at which the reward is scheduled.Err(DispatchError)- otherwise.Ok(TimeStamp)- the block number at which the reward is scheduled.Err(DispatchError)- otherwise.
Source§fn reclaim(
who: &Author<T>,
from: Self::TimeStamp,
) -> Result<Self::Asset, DispatchError>
fn reclaim( who: &Author<T>, from: Self::TimeStamp, ) -> Result<Self::Asset, DispatchError>
Removes a pending reward for a given author, effectively regaining it from a particular timestamp scheduled.
It allows the system to revoke a scheduled reward that has not yet been finalized,
identified by the specific timestamp (from) at which the reward was originally set
for enforcement.
Regaining cannot apply to rewards at or before the finalized block height.
§Returns
Ok(Asset)- the total reward that was successfully regained.Err(DispatchError)- otherwise
Source§fn on_reward(who: &Author<T>, amount: Self::Asset, at: Self::TimeStamp)
fn on_reward(who: &Author<T>, amount: Self::Asset, at: Self::TimeStamp)
Hook invoked when reward is scheduled or applied to an author.
Emits Event::AuthorRewardScheduled if Config::EmitEvents is true.
Source§fn on_reclaim(who: &Author<T>, amount: Self::Asset)
fn on_reclaim(who: &Author<T>, amount: Self::Asset)
Hook invoked when an author’s scheduled rewards are reclaimed.
Emits Event::AuthorRewardReclaimed if Config::EmitEvents is true.
Source§fn on_set_hold(who: &Author<T>, value: Self::Asset)
fn on_set_hold(who: &Author<T>, value: Self::Asset)
Hook invoked when an author’s hold balance is updated.
Emits Event::AuthorTotalHold if Config::EmitEvents is true.
Source§fn on_forgive(who: &Author<T>, factor: Self::Ratio)
fn on_forgive(who: &Author<T>, factor: Self::Ratio)
Hook invoked when an author’s scheduled penalty is forgiven.
Emits Event::AuthorPenaltyForgiven if Config::EmitEvents is true.
Source§fn on_penalize(who: &Author<T>, factor: Self::Ratio, at: Self::TimeStamp)
fn on_penalize(who: &Author<T>, factor: Self::Ratio, at: Self::TimeStamp)
Hook invoked when penality is scheduled or applied to an author.
Emits Event::AuthorPenaltyScheduled if Config::EmitEvents is true.
Source§impl<T: Config> FundRoles<<T as Config>::AccountId> for Pallet<T>
Implements the FundRoles trait for the Author subsystem
impl<T: Config> FundRoles<<T as Config>::AccountId> for Pallet<T>
Implements the FundRoles trait for the Author subsystem
Defines how authors can be externally backed by external collaterals within the runtime.
Source§type Backer = Funder<T>
type Backer = Funder<T>
Represents the entity providing funding to an author.
Can be a direct account, an index, or a managed pool.
Indirect backers such as index or pools must have a direct account willing to back (fund) it.
Source§fn has_funds(who: &Author<T>) -> DispatchResult
fn has_funds(who: &Author<T>) -> DispatchResult
Checks if the author has any active backers/funds.
Returns a DispatchError if no funders exist.
Source§fn max_exposure(
by: &Self::Backer,
to: &Author<T>,
precision: Precision,
force: Fortitude,
) -> Result<Self::Asset, DispatchError>
fn max_exposure( by: &Self::Backer, to: &Author<T>, precision: Precision, force: Fortitude, ) -> Result<Self::Asset, DispatchError>
Returns the maximum exposure allowed for an Author from a Backer,
under the directive of the attempted funding.
For Funder::Direct backers, limits are derived from:
- global constraint (
MaxExposure), - author-specific constraint (
AuthorInfo’smax_fund), - and underlying commitment limits via
CommitmentAdapter, depending on whether the fund is new or being raised.
For index and pool funders:
- only global and author-specific constraints are applied.
The precision and force parameters simulate the directive of
the funding attempt.
Source§fn min_fund(
by: &Self::Backer,
to: &Author<T>,
precision: Precision,
force: Fortitude,
) -> Result<Self::Asset, DispatchError>
fn min_fund( by: &Self::Backer, to: &Author<T>, precision: Precision, force: Fortitude, ) -> Result<Self::Asset, DispatchError>
Returns the minimum funding amount required for a Backer to fund
an Author, under the directive of the attempted funding.
For Funder::Direct backers, limits are derived from:
- global constraint (
MinFund), - author-specific constraint (
AuthorInfo’smin_fund), - and underlying commitment limits via
CommitmentAdapter, depending on whether the fund is new or being raised.
For index and pool funders:
- only global and author-specific constraints are applied.
The precision and force parameters simulate the directive of
the funding attempt.
Source§fn backed_value(who: &Author<T>) -> Result<Self::Asset, DispatchError>
fn backed_value(who: &Author<T>) -> Result<Self::Asset, DispatchError>
Total real-time funds currently backing the author (excluding the author’s own collateral).
Only includes finalized commitments; pending rewards or penalties are ignored.
Source§fn total_backing() -> Self::Asset
fn total_backing() -> Self::Asset
Total real-time funds currently backing all the authors (excluding all authors own collaterals).
Only includes finalized commitments; pending rewards or penalties are ignored.
Source§fn can_fund(
by: &Self::Backer,
to: &Author<T>,
value: Self::Asset,
precision: Precision,
force: Fortitude,
) -> DispatchResult
fn can_fund( by: &Self::Backer, to: &Author<T>, value: Self::Asset, precision: Precision, force: Fortitude, ) -> DispatchResult
Validates whether a backer can fund a given author.
Returns Ok(()) if the backer is eligible to fund, or a DispatchError otherwise.
Source§fn fund(
to: &Author<T>,
by: &Self::Backer,
value: Self::Asset,
precision: Precision,
force: Fortitude,
) -> Result<Self::Asset, DispatchError>
fn fund( to: &Author<T>, by: &Self::Backer, value: Self::Asset, precision: Precision, force: Fortitude, ) -> Result<Self::Asset, DispatchError>
Funds an author on behalf of a backer.
This function either places a new fund for an author or increases an existing fund if the author has already been funded by the same backer.
The backer Self::Backer is of type Funder in itself explains to
whom its funding, and via what.
This function asks a suitable author to diligently even for index and pool backers.
It is never unused as we can do additional invariant checks.
Hence indexes and pool backers should ensure that the author given is indeed true in its context of valdidation i.e., author available in respective entires or slots.
In case of backers being index or pools, the returned amount reflects the total funding to it (may not be only for the given author)
§Returns
Ok(Asset): The amount successfully funded.Err(DispatchError)otherwise.
Source§fn can_draw(by: &Self::Backer, from: &Author<T>) -> DispatchResult
fn can_draw(by: &Self::Backer, from: &Author<T>) -> DispatchResult
Validates whether a backer can withdraw their existing fund from a given author.
The backer Self::Backer is of type Funder in itself explains to
whom its funded, and via what.
This function asks a suitable author from diligently even for index and pool backers.
It is never unused as we can do additional invariant checks.
Hence indexes and pool backers should ensure that the author given is indeed true in its context of valdidation i.e., author available in respective entires or slots.
Returns Ok(()) if the backer is eligible to withdraw the fund, or a DispatchError otherwise.
Source§fn draw(
from: &Author<T>,
by: &Self::Backer,
) -> Result<Self::Asset, DispatchError>
fn draw( from: &Author<T>, by: &Self::Backer, ) -> Result<Self::Asset, DispatchError>
Withdraws funds for a given author on behalf of a backer.
This function allows a backer to “draw” or withdraw funds that were committed to an author. Depending on the type of backer, the withdrawal behaves slightly differently:
- Direct Backer: Withdraws the funds directly committed by the backer.
- Index Backer: Withdraws the total funds of the specified index, assuming the author is part of it.
- Pool Backer: Withdraws the total funds of the pool, assuming the author is part of it.
Returns the withdrawn amount on success, or a DispatchError if validation fails.
Source§fn backers_of(
who: &Author<T>,
) -> Result<Vec<(Self::Backer, Self::Asset)>, DispatchError>
fn backers_of( who: &Author<T>, ) -> Result<Vec<(Self::Backer, Self::Asset)>, DispatchError>
Returns all backers currently funding the given author along with their real-time contributions.
This excludes the author’s own collateral as only external backers are returned.
This function iterates over each registered funder for the author and retrieves their committed value:
- Direct: Returns the committed amount.
- Index: Fetches the value of the author’s (entry’s) digest within the index’s digest’s entries.
- Pool: Fetches the value of the author’s (slot’s) digest within the pool’s digest’s slots.
Returns a vector of (Backer, Asset) tuples or a DispatchError if any validation fails.
Source§fn backed_for(
by: &Self::Backer,
) -> Result<Vec<(Author<T>, Self::Asset)>, DispatchError>
fn backed_for( by: &Self::Backer, ) -> Result<Vec<(Author<T>, Self::Asset)>, DispatchError>
Returns all authors currently funded by the given backer as external funding along with their real-time contributions.
Behavior varies by backer type:
- Direct: Expected to fund a single author; retrieves the commit digest and value.
- Index: Can fund multiple authors; retrieves all index entries as digests and values for the backing account.
- Pool: Can fund multiple authors; retrieves all pool slots as digests and values for the backing account.
After retrieving digests and values, this function resolves each digest to the corresponding author and ensures that the author exists.
Returns a vector of (Author, Asset) tuples, or a DispatchError if validation fails.
Source§fn get_fund(
who: &Author<T>,
by: &Self::Backer,
) -> Result<Self::Asset, DispatchError>
fn get_fund( who: &Author<T>, by: &Self::Backer, ) -> Result<Self::Asset, DispatchError>
Returns the real-time contribution a specific backer has funded to the given author.
Behavior varies by backer type:
- Direct: Expects a single author; verifies that the digest maps to the given author.
- Index: Returns the value of the author’s entry in the index for the backer account.
- Pool: Returns the value of the author’s slot in the pool for the backer account.
Returns the funded Asset or a DispatchError if validation fails.
Source§fn on_drawn(who: &Author<T>, by: &Self::Backer, amount: Self::Asset)
fn on_drawn(who: &Author<T>, by: &Self::Backer, amount: Self::Asset)
Hook invoked after a backer withdraws previously committed funds from an author, via direct, index, or pool commitments.
For index or pool backers, the emitted amount represents the aggregated withdrawal applied across all associated authors.
Emits any one of event if Config::EmitEvents is true.
- Direct Author: Event::AuthorDrawn
- Index: Event::IndexDrawn
- Pool: Event::PoolDrawn
Source§fn on_funded(who: &Author<T>, by: &Self::Backer, amount: Self::Asset)
fn on_funded(who: &Author<T>, by: &Self::Backer, amount: Self::Asset)
Hook invoked after an author is successfully funded by a backer.
For index or pool backers, the emitted amount represents the aggregated deposit distributed across all associated authors.
Emits any one of event if Config::EmitEvents is true.
- Direct Author: Event::AuthorFunded
- Index: Event::IndexFunded
- Pool: Event::PoolFunded
Source§impl<T: Config> GetStorageVersion for Pallet<T>
impl<T: Config> GetStorageVersion for Pallet<T>
Source§type InCodeStorageVersion = NoStorageVersionSet
type InCodeStorageVersion = NoStorageVersionSet
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
Apply scheduled author rewards and penalties at the start of each block.
- Rewards and penalties must be processed before any new extrinsics or elections in the current block to ensure that subsequent computations are accurate.
- By processing at the start, we disallow querying or relying on the current block’s rewards/penalties until the next block, ensuring deterministic behavior and avoiding double-counting or race conditions.
- Rewards/penalties are applied once per block at the beginning.
- This ensures deterministic, predictable state transitions, and makes querying the pallet consistent (no author sees their reward/penalty applied mid-block).
§fn on_finalize(_n: BlockNumber)
fn on_finalize(_n: BlockNumber)
§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: Config> RoleManager<<T as Config>::AccountId> for Pallet<T>
Implements the RoleManager trait for the Author subsystem
impl<T: Config> RoleManager<<T as Config>::AccountId> for Pallet<T>
Implements the RoleManager trait for the Author subsystem
Defines how authors behave as role-bearing entities within the runtime.
Source§type Status = AuthorStatus
type Status = AuthorStatus
The possible states of an Author role.
Variants:
Active: Author is actively participating.Probation: Author is under review or subject to restrictions.Resigned: Author voluntarily left the role.
Note: There is no explicit suspension; penalties and probation are applied to enforce decentralization.
Source§type Meta = AuthorInfo<T>
type Meta = AuthorInfo<T>
The meta-information of an Author role.
Source§type Asset = <<T as Config>::CommitmentAdapter as InspectAsset<<T as Config>::AccountId>>::Asset
type Asset = <<T as Config>::CommitmentAdapter as InspectAsset<<T as Config>::AccountId>>::Asset
The type representing the collateral or hold of an Author role.
Source§type TimeStamp = <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number
type TimeStamp = <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number
Timestamp type used for enrollment or status tracking.
Source§fn role_exists(who: &Author<T>) -> DispatchResult
fn role_exists(who: &Author<T>) -> DispatchResult
Checks whether the given Author exists in the system.
Returns:
Ok(())if the author exists.Err(DispatchError)otherwise.
Source§fn get_meta(who: &Author<T>) -> Result<Self::Meta, DispatchError>
fn get_meta(who: &Author<T>) -> Result<Self::Meta, DispatchError>
Retrieves the meta-data of the given Author if available.
Returns:
Ok(Meta)if the author exists.Err(DispatchError)otherwise.
Source§fn get_collateral(who: &Author<T>) -> Result<Self::Asset, DispatchError>
fn get_collateral(who: &Author<T>) -> Result<Self::Asset, DispatchError>
Retrieves the amount of collateral currently locked by an Author during
enrollment.
This ensures real-time accuracy, reflecting any updates to the collateral.
- Does not check author validaity, since commitment call reflects if the pallet-gated collateral reason is funded by the given author
- Invariant:
FreezeReason::AuthorCollateralmust only be utilized by this pallet - Invariant: Ensures the collateral must be non-zero, or else most of the functions will fail.
Returns the collateral value or a DispatchError otherwise.
Source§fn total_collateral() -> Self::Asset
fn total_collateral() -> Self::Asset
Retrieves the amount of collateral currently locked by all Authors during
enrollment.
This ensures real-time accuracy, reflecting any updates to any collaterals.
Source§fn enroll_since(who: &Author<T>) -> Result<Self::TimeStamp, DispatchError>
fn enroll_since(who: &Author<T>) -> Result<Self::TimeStamp, DispatchError>
Returns the block number when the Author enrolled in the role.
DispatchError otherwise
Source§fn get_status(who: &Author<T>) -> Result<Self::Status, DispatchError>
fn get_status(who: &Author<T>) -> Result<Self::Status, DispatchError>
Retrieves the current status of the given Author.
Status can be one of:
ActiveProbationResigned
DispatchError otherwise
Source§fn status_since(who: &Author<T>) -> Result<Self::TimeStamp, DispatchError>
fn status_since(who: &Author<T>) -> Result<Self::TimeStamp, DispatchError>
Returns the timestamp (block number) when the author’s current status was last updated.
This can be used to track how long an author has been in a specific state (e.g., probation, active, resigned) and enforce time-based rules.
DispatchError otherwise.
Source§fn set_status(who: &Author<T>, status: Self::Status) -> DispatchResult
fn set_status(who: &Author<T>, status: Self::Status) -> DispatchResult
Updates the status of an author in a safe, controlled way.
It doesn’t mutate status directly, but enforces validations to proceed.
DispatchError otherwise.
Source§fn can_enroll(who: &Author<T>, collateral: Self::Asset) -> DispatchResult
fn can_enroll(who: &Author<T>, collateral: Self::Asset) -> DispatchResult
Validates whether an Author can enroll with the given collateral.
Checks include:
- If the status is
Resigned, enrollment is allowed (re-entry). - Ensures the provided collateral meets the minimum requirement.
Returns:
Ok(())if all checks pass.- `Err(DispatchError) otheriwse.
Source§fn enroll(
who: &Author<T>,
collateral: Self::Asset,
force: Fortitude,
) -> Result<Self::Asset, DispatchError>
fn enroll( who: &Author<T>, collateral: Self::Asset, force: Fortitude, ) -> Result<Self::Asset, DispatchError>
Enrolls a new author with the specified collateral and the operation’s
priviledge via force.
Steps performed:
- Ensure the author is eligible and the collateral meets minimum requirements.
- Generate a unique digest/hash for this author’s funding commitment.
- Lock the collateral using the commitment adapter.
- Register the author in storage and maintain lookup maps.
For Resigned Authors Enrollment, their commitment-digest is reused.
§force Semantics
- [
Fortitude::Polite]: Uses funds from the commitment reserve. - [
Fortitude::Force]: Uses funds from the user’s liquid balance.
Prefer Polite when collateral is pre-reserved; otherwise use Force.
This operation will never kill an account, as guaranteed by the commitment system.
§Errors
- Returns the actual amount of collateral successfully reserved.
- Returns a
DispatchErrorif fails.
Source§fn can_resign(who: &Author<T>) -> DispatchResult
fn can_resign(who: &Author<T>) -> DispatchResult
Validates whether an Author can safely resign from the role.
Checks include:
- Author in
Probationcannot resign (must resolve probation first). - Ensures there are no pending penalties.
- Ensures the author is not currently active in duties (cannot resign while active).
Pending rewards are ignored, as its voluntary for author to resign before receiving the rewards, whereas the backers are unaffected for receiving.
Returns:
Ok(())if all conditions are met.- `Err(DispatchError) otherwise.
Source§fn resign(who: &Author<T>) -> Result<Self::Asset, DispatchError>
fn resign(who: &Author<T>) -> Result<Self::Asset, DispatchError>
Resigns an author, releasing collateral and updating status.
Marks author’s status as Resigned (so funders may withdraw their funds later).
If an author’s metadata is ever reaped, a separate, safety-checked procedure
MUST ensure that all funders have fully withdrawn their commitments.
Only once this invariant holds it is safe to issue a new digest and purge
the old entry from AuthorsDigest during re-enrollment.
This function does not perform those checks and MUST NOT be used for that purpose.
Returns the refunded collateral of the author. DispatchError otherwise.
Source§fn add_collateral(
who: &Author<T>,
collateral: Self::Asset,
force: Fortitude,
) -> Result<Self::Asset, DispatchError>
fn add_collateral( who: &Author<T>, collateral: Self::Asset, force: Fortitude, ) -> Result<Self::Asset, DispatchError>
Increases the collateral for an Author with the specified collateral
and the operation’s priviledge (force).
If the existing collateral (before raising/adding) is lesser than the system enforced
minimum, this function uses [Precision::Exact] else [Precision::BestEffort].
force determines the source of funds:
- [
Fortitude::Polite]: commitment reserve - [
Fortitude::Force]: liquid balance
Returns the actually raised collateral (not full collateral). DispatchError otherwise.
Source§fn is_available(who: &Author<T>) -> DispatchResult
fn is_available(who: &Author<T>) -> DispatchResult
Checks if the author is not defaulted (available).
- Active or Probation authors are not considered defaulted (returns error).
- Resigned authors are treated as defaulted.
- Lesser Collateral will result in author being defaulted.
Source§fn on_enroll(who: &Author<T>, collateral: Self::Asset)
fn on_enroll(who: &Author<T>, collateral: Self::Asset)
Hook invoked after an author is successfully enrolled.
Emits Event::AuthorEnlisted if Config::EmitEvents is true.
Source§fn on_resign(who: &Author<T>, released: Self::Asset)
fn on_resign(who: &Author<T>, released: Self::Asset)
Hook invoked when an author resignation is processed.
Emits Event::AuthorResigned if Config::EmitEvents is true.
Source§fn on_add_collateral(who: &Author<T>, raised: Self::Asset)
fn on_add_collateral(who: &Author<T>, raised: Self::Asset)
Hook invoked after an author’s collateral balance is incremented.
Emits Event::AuthorCollateralRaised if Config::EmitEvents is true.
Source§fn on_status_update(who: &Author<T>, status: &Self::Status)
fn on_status_update(who: &Author<T>, status: &Self::Status)
Hook invoked after an author’s status is mutated or updated.
Emits Event::AuthorStatus if Config::EmitEvents is true.
Source§impl<T: Config> RoleProbation<<T as Config>::AccountId> for Pallet<T>
Implements the RoleProbation trait for the Author subsystem
impl<T: Config> RoleProbation<<T as Config>::AccountId> for Pallet<T>
Implements the RoleProbation trait for the Author subsystem
Defines how authors can be switched between probation and permenance with certain invariants enforced for good behavior.
Source§fn is_on_probation(who: &Author<T>) -> DispatchResult
fn is_on_probation(who: &Author<T>) -> DispatchResult
Checks if the author is currently under probation.
Returns Ok(()) if the author is in Probation status.
DispatchError of current status of author otherwise.
Source§fn is_permanent(who: &Author<T>) -> DispatchResult
fn is_permanent(who: &Author<T>) -> DispatchResult
Checks if the author has secured permanent (active) status.
Returns Ok(()) if the author is Active (permanent).
DispatchError of current status of author otherwise.
Source§fn can_be_permanent(who: &Author<T>) -> DispatchResult
fn can_be_permanent(who: &Author<T>) -> DispatchResult
Checks if the given author is eligible to become permanent.
Evaluates risk status and requires author in probation.
- Returns
Ok(())if the author can be promoted to permanent status. - Returns
Err(DispatchError)otherwise.
Source§fn set_permanence(who: &Author<T>) -> Result<Self::Status, DispatchError>
fn set_permanence(who: &Author<T>) -> Result<Self::Status, DispatchError>
Promotes an author to permanent/active status.
Returns Ok(AuthorStatus::Active) on success or Err(DispatchError) otherwise.
Source§fn can_revoke_permanence(who: &Author<T>) -> DispatchResult
fn can_revoke_permanence(who: &Author<T>) -> DispatchResult
Checks if the given author is eligible to be placed back under probation.
Passes if indication of significant risk on active authors.
- Returns
Ok(())if the author can be probated. - Returns
Err(DispatchError)if the author is already in probation, resigned, or cannot be probated.
Source§fn revoke_permanence(who: &Author<T>) -> Result<Self::Status, DispatchError>
fn revoke_permanence(who: &Author<T>) -> Result<Self::Status, DispatchError>
Revokes an author’s permanent/active status and places them back under probation.
Returns Ok(AuthorStatus::Probation) on success or Err(DispatchError) otherwise.
Source§fn risk_probation(who: &Author<T>) -> DispatchResult
fn risk_probation(who: &Author<T>) -> DispatchResult
Marks a probationary author as at risk, extending their risk magnitude.
- Returns
Ok(())on success orErr(DispatchError)otherwise.
Source§fn risk_permanence(who: &Author<T>) -> DispatchResult
fn risk_permanence(who: &Author<T>) -> DispatchResult
Marks a permanent/active author as at risk, potentially impacting their permanence.
- Returns
Ok(())on success orErr(DispatchError)otherwise.
Source§fn secure_permanence(who: &Author<T>) -> DispatchResult
fn secure_permanence(who: &Author<T>) -> DispatchResult
Reduces the risk period for an author, securing their permanence.
- Returns
Ok(())on success orErr(DispatchError)otherwise.
Source§fn on_set_permance(who: &Author<T>)
fn on_set_permance(who: &Author<T>)
Hook invoked after an author is promoted to permanent (Active) status.
Emits Event::AuthorStatus if Config::EmitEvents is true.
Source§fn on_revoke_permanence(who: &Author<T>)
fn on_revoke_permanence(who: &Author<T>)
Hook invoked after an author’s permanence is revoked.
Emits Event::AuthorStatus if Config::EmitEvents is true.
Source§fn on_risk_permanence(who: &Author<T>)
fn on_risk_permanence(who: &Author<T>)
Hook invoked when risk is applied to an author increasing their risk towards disinheriting permanace.
Emits Event::AuthorAtRisk if Config::EmitEvents is true.
Source§fn on_risk_probation(who: &Author<T>)
fn on_risk_probation(who: &Author<T>)
Hook invoked when risk is applied to an author increasing their risk to inherit permanace.
Emits Event::AuthorAtRisk if Config::EmitEvents is true.
Source§fn on_secure_permanence(who: &Author<T>)
fn on_secure_permanence(who: &Author<T>)
Hook invoked when risk is reduced to an author increasing their oppurtunity to inherit permanace.
Emits Event::AuthorAtRisk if Config::EmitEvents is true.
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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<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 moreSource§impl<T, U, Tag> IntoTag<U, Tag> for Twhere
U: FromTag<T, Tag>,
Tag: DiscriminantTag,
impl<T, U, Tag> IntoTag<U, Tag> for Twhere
U: FromTag<T, Tag>,
Tag: DiscriminantTag,
§impl<Src, Dest> IntoTuple<Dest> for Srcwhere
Dest: FromTuple<Src>,
impl<Src, Dest> IntoTuple<Dest> for Srcwhere
Dest: FromTuple<Src>,
fn into_tuple(self) -> Dest
§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
Source§impl<T, Time> Logging<Time> for Twhere
Time: Time,
impl<T, Time> Logging<Time> for Twhere
Time: Time,
Source§const FALLBACK_TARGET: &'static str = "routine"
const FALLBACK_TARGET: &'static str = "routine"
Default logging target if none is provided.
Most routines, especially offchain workers or background tasks, use this target for simplicity.
It allows a consistent place to look for routine logs without requiring every call to specify a target.
Note: This target is only a conveninence and may be somewhat vague. To ensure errors can still be traced accurately, the logged messages should include additional metadata (e.g., module name, error index, or contextual info) so that the source of the error can be identified even if the target is generic.
Source§type Logger = DispatchError
type Logger = DispatchError
The type taken and returned for logging.
We simply return the same [DispatchError] that was logged,
so logging does not change control flow or error propagation.
DispatchError is used because in Substrate it encompasses all
runtime errors - including module errors, token errors, arithmetic
issues, and transactional boundaries - making it the universal
substrate-side error representation.
Source§type Level = LogLevel
type Level = LogLevel
The log level type.
We use the LogLevel enum to standardize severity levels
(Info, Warn, Error, Debug) across all routine logs.
Source§fn log(
level: <T as Logging<Time>>::Level,
err: &<T as Logging<Time>>::Logger,
timestamp: Time,
target: Option<&str>,
fmt: Option<fn(Time, &<T as Logging<Time>>::Level, &str, &str) -> String>,
) -> <T as Logging<Time>>::Logger
fn log( level: <T as Logging<Time>>::Level, err: &<T as Logging<Time>>::Logger, timestamp: Time, target: Option<&str>, fmt: Option<fn(Time, &<T as Logging<Time>>::Level, &str, &str) -> String>, ) -> <T as Logging<Time>>::Logger
Source§fn info(
err: &Self::Logger,
timestamp: Timestamp,
target: Option<&str>,
fmt: Option<fn(Timestamp, &Self::Level, &str, &str) -> String>,
) -> Self::Loggerwhere
Self: Sized,
fn info(
err: &Self::Logger,
timestamp: Timestamp,
target: Option<&str>,
fmt: Option<fn(Timestamp, &Self::Level, &str, &str) -> String>,
) -> Self::Loggerwhere
Self: Sized,
Source§fn warn(
err: &Self::Logger,
timestamp: Timestamp,
target: Option<&str>,
fmt: Option<fn(Timestamp, &Self::Level, &str, &str) -> String>,
) -> Self::Loggerwhere
Self: Sized,
fn warn(
err: &Self::Logger,
timestamp: Timestamp,
target: Option<&str>,
fmt: Option<fn(Timestamp, &Self::Level, &str, &str) -> String>,
) -> Self::Loggerwhere
Self: Sized,
§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<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.