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>;
// 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§
sourcefn new(who: &AccountId, new: Footprint) -> Result<Self, DispatchError>
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.
sourcefn update(self, who: &AccountId, new: Footprint) -> Result<Self, DispatchError>
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.
sourcefn drop(self, who: &AccountId) -> Result<(), DispatchError>
fn drop(self, who: &AccountId) -> Result<(), DispatchError>
Consume a ticket for some old
footprint attributable to who
which should now been freed.
Provided Methods§
sourcefn burn(self, _: &AccountId)
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.