mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 00:37:57 +00:00
[contracts] Adapt storage reading host functions to Weights V2 (#12976)
* update RuntimeCosts to Weights V2, update tests * improve docs * clearer naming and docs to compat_weight helper * Apply suggestions from code review Co-authored-by: Alexander Theißen <alex.theissen@me.com> * save before master merge * HostFnWeights to Weight * added to_weight! macro * Apply suggestions from code review Co-authored-by: Alexander Theißen <alex.theissen@me.com> * RuntimeCosts::ChainExtension to weight_v2 * chain extension to weight v2 Co-authored-by: Alexander Theißen <alex.theissen@me.com>
This commit is contained in:
@@ -122,23 +122,23 @@ fn iterate_fields(data: &syn::DataStruct, fmt: impl Fn(&Ident) -> TokenStream2)
|
||||
|
||||
fn format_weight(field: &Ident) -> TokenStream2 {
|
||||
quote_spanned! { field.span() =>
|
||||
&if self.#field > 1_000_000_000 {
|
||||
&if self.#field.ref_time() > 1_000_000_000 {
|
||||
format!(
|
||||
"{:.1?} ms",
|
||||
Fixed::saturating_from_rational(self.#field, 1_000_000_000).to_float()
|
||||
Fixed::saturating_from_rational(self.#field.ref_time(), 1_000_000_000).to_float()
|
||||
)
|
||||
} else if self.#field > 1_000_000 {
|
||||
} else if self.#field.ref_time() > 1_000_000 {
|
||||
format!(
|
||||
"{:.1?} µs",
|
||||
Fixed::saturating_from_rational(self.#field, 1_000_000).to_float()
|
||||
Fixed::saturating_from_rational(self.#field.ref_time(), 1_000_000).to_float()
|
||||
)
|
||||
} else if self.#field > 1_000 {
|
||||
} else if self.#field.ref_time() > 1_000 {
|
||||
format!(
|
||||
"{:.1?} ns",
|
||||
Fixed::saturating_from_rational(self.#field, 1_000).to_float()
|
||||
Fixed::saturating_from_rational(self.#field.ref_time(), 1_000).to_float()
|
||||
)
|
||||
} else {
|
||||
format!("{} ps", self.#field)
|
||||
format!("{} ps", self.#field.ref_time())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user