git.delta.rocks / unique-network / refs/commits / 430b0201ea83

difftreelog

source

pallets/common/src/helpers.rs739 Bsourcehistory
1//! # Helpers module2//!3//! The module contains helpers.4//!5use frame_support::{6	dispatch::{DispatchErrorWithPostInfo, PostDispatchInfo},7	pallet_prelude::DispatchResultWithPostInfo,8	weights::Weight,9};1011/// Add weight for a `DispatchResultWithPostInfo`12///13/// - `target`: DispatchResultWithPostInfo to which weight will be added14/// - `additional_weight`: Weight to be added15pub fn add_weight_to_post_info(target: &mut DispatchResultWithPostInfo, additional_weight: Weight) {16	match target {17		Ok(PostDispatchInfo {18			actual_weight: Some(weight),19			..20		})21		| Err(DispatchErrorWithPostInfo {22			post_info: PostDispatchInfo {23				actual_weight: Some(weight),24				..25			},26			..27		}) => *weight += additional_weight,28		_ => {}29	}30}