mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 13:17:56 +00:00
Do a refund based on the actual weight (#5584)
This refunds weight and the weight bases fee back to the sender of an extrinsic after the dispatch.
This commit is contained in:
committed by
GitHub
parent
8e0d01570f
commit
bd91e58a9a
@@ -139,6 +139,21 @@ pub struct PostDispatchInfo {
|
||||
pub actual_weight: Option<Weight>,
|
||||
}
|
||||
|
||||
impl PostDispatchInfo {
|
||||
/// Calculate how much (if any) weight was not used by the `Dispatchable`.
|
||||
pub fn calc_unspent(&self, info: &DispatchInfo) -> Weight {
|
||||
if let Some(actual_weight) = self.actual_weight {
|
||||
if actual_weight >= info.weight {
|
||||
0
|
||||
} else {
|
||||
info.weight - actual_weight
|
||||
}
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Option<Weight>> for PostDispatchInfo {
|
||||
fn from(actual_weight: Option<Weight>) -> Self {
|
||||
Self {
|
||||
|
||||
Reference in New Issue
Block a user