pub trait Consideration<AccountId>: 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>;

    // 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.

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> Consideration<A> for ()

Implementors§

source§

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

source§

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

source§

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

source§

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