Trait xcm_executor::traits::WeightTrader
source · pub trait WeightTrader: Sized {
// Required methods
fn new() -> Self;
fn buy_weight(
&mut self,
weight: Weight,
payment: Assets,
context: &XcmContext
) -> Result<Assets, XcmError>;
// Provided method
fn refund_weight(
&mut self,
_weight: Weight,
_context: &XcmContext
) -> Option<MultiAsset> { ... }
}
Expand description
Charge for weight in order to execute XCM.
A WeightTrader
may also be put into a tuple, in which case the default behavior of
buy_weight
and refund_weight
would be to attempt to call each tuple element’s own
implementation of these two functions, in the order of which they appear in the tuple,
returning early when a successful result is returned.
Required Methods§
sourcefn buy_weight(
&mut self,
weight: Weight,
payment: Assets,
context: &XcmContext
) -> Result<Assets, XcmError>
fn buy_weight( &mut self, weight: Weight, payment: Assets, context: &XcmContext ) -> Result<Assets, XcmError>
Purchase execution weight credit in return for up to a given payment
. If less of the
payment is required then the surplus is returned. If the payment
cannot be used to pay
for the weight
, then an error is returned.
Provided Methods§
sourcefn refund_weight(
&mut self,
_weight: Weight,
_context: &XcmContext
) -> Option<MultiAsset>
fn refund_weight( &mut self, _weight: Weight, _context: &XcmContext ) -> Option<MultiAsset>
Attempt a refund of weight
into some asset. The caller does not guarantee that the weight
was purchased using buy_weight
.
Default implementation refunds nothing.