referrerpolicy=no-referrer-when-downgrade

Trait frame_support::traits::Consideration

source ·
pub trait Consideration<AccountId, Footprint>: Member + FullCodec + TypeInfo + MaxEncodedLen {
    // Required methods
    fn new(who: &AccountId, new: Footprint) -> Result<Self, DispatchError>;
    fn update(
        self,
        who: &AccountId,
        new: Footprint,
    ) -> Result<Self, DispatchError>;
    fn drop(self, who: &AccountId) -> Result<(), DispatchError>;
    fn ensure_successful(who: &AccountId, new: Footprint);

    // Provided method
    fn burn(self, _: &AccountId) { ... }
}
Expand description

Some sort of cost taken from account temporarily in order to offset the cost to the chain of holding some data Footprint in state.

The cost may be increased, reduced or dropped entirely as the footprint changes.

A single ticket corresponding to some particular datum held in storage. This is an opaque type, but must itself be stored and generally it should be placed alongside whatever data the ticket was created for.

While not technically a linear type owing to the need for FullCodec, this should be treated as one. Don’t type to duplicate it, and remember to drop it when you’re done with it.

Required Methods§

source

fn new(who: &AccountId, new: Footprint) -> Result<Self, DispatchError>

Create a ticket for the new footprint attributable to who. This ticket must ultimately be consumed through update or drop once the footprint changes or is removed.

source

fn update(self, who: &AccountId, new: Footprint) -> Result<Self, DispatchError>

Optionally consume an old ticket and alter the footprint, enforcing the new cost to who and returning the new ticket (or an error if there was an issue).

For creating tickets and dropping them, you can use the simpler new and drop instead.

source

fn drop(self, who: &AccountId) -> Result<(), DispatchError>

Consume a ticket for some old footprint attributable to who which should now been freed.

source

fn ensure_successful(who: &AccountId, new: Footprint)

Ensure that creating a ticket for a given account and footprint will be successful if done immediately after this call.

Provided Methods§

source

fn burn(self, _: &AccountId)

Consume a ticket for some old footprint attributable to who which should be sacrificed.

This is infallible. In the general case (and it is left unimplemented), then it is equivalent to the consideration never being dropped. Cases which can handle this properly should implement, but it MUST rely on the loss of the consideration to the owner.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<A, F> Consideration<A, F> for ()

source§

fn new(_: &A, _: F) -> Result<Self, DispatchError>

source§

fn update(self, _: &A, _: F) -> Result<(), DispatchError>

source§

fn drop(self, _: &A) -> Result<(), DispatchError>

source§

fn ensure_successful(_: &A, _: F)

Implementors§

source§

impl<A: 'static + Eq, F: 'static + MutateFreeze<A> + Mutate<A>, R: 'static + Get<F::Id>, D: 'static + Convert<Fp, F::Balance>, Fp: 'static> Consideration<A, Fp> for FreezeConsideration<A, F, R, D, Fp>

source§

impl<A: 'static + Eq, F: 'static + MutateHold<A> + Mutate<A>, R: 'static + Get<F::Reason>, D: 'static + Convert<Fp, F::Balance>, Fp: 'static> Consideration<A, Fp> for HoldConsideration<A, F, R, D, Fp>

source§

impl<A: 'static + Eq, F: 'static + MutateHold<A> + Mutate<A>, R: 'static + Get<F::Reason>, D: 'static + Convert<Fp, F::Balance>, Fp: 'static> Consideration<A, Fp> for LoneHoldConsideration<A, F, R, D, Fp>

source§

impl<A: 'static + Eq, Fx: 'static + MutateFreeze<A> + Mutate<A>, Rx: 'static + Get<Fx::Id>, D: 'static + Convert<Fp, Fx::Balance>, Fp: 'static> Consideration<A, Fp> for LoneFreezeConsideration<A, Fx, Rx, D, Fp>