referrerpolicy=no-referrer-when-downgrade

Trait polkadot_sdk_frame::traits::Consideration

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§

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.

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.

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

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

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§

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§

§

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

§

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

§

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

§

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

§

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

Implementors§

§

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

§

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

§

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

§

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