Type Alias frame_system::pallet::BlockWeight

source ·
pub type BlockWeight<T: Config> = StorageValue<_GeneratedPrefixForStorageBlockWeight<T>, ConsumedWeight, ValueQuery>;
Expand description

The current weight for the block.

Storage type is StorageValue with value type ConsumedWeight.

Aliased Type§

struct BlockWeight<T: Config>(/* private fields */);

Implementations

source§

impl<Prefix, Value, QueryKind, OnEmpty> StorageValue<Prefix, Value, QueryKind, OnEmpty>
where Prefix: StorageInstance, Value: FullCodec, QueryKind: QueryKindTrait<Value, OnEmpty>, OnEmpty: Get<<QueryKind as QueryKindTrait<Value, OnEmpty>>::Query> + 'static,

source

pub fn hashed_key() -> [u8; 32]

Get the storage key.

source

pub fn exists() -> bool

Does the value (explicitly) exist in storage?

source

pub fn get() -> <QueryKind as QueryKindTrait<Value, OnEmpty>>::Query

Load the value from the provided storage instance.

source

pub fn try_get() -> Result<Value, ()>

Try to get the underlying value from the provided storage instance; Ok if it exists, Err if not.

source

pub fn translate<O, F>(f: F) -> Result<Option<Value>, ()>
where O: Decode, F: FnOnce(Option<O>) -> Option<Value>,

Translate a value from some previous type (O) to the current type.

f: F is the translation function.

Returns Err if the storage item could not be interpreted as the old type, and Ok, along with the new value if it could.

NOTE: This operates from and to Option<_> types; no effort is made to respect the default value of the original type.

§Warning

This function must be used with care, before being updated the storage still contains the old type, thus other calls (such as get) will fail at decoding it.

§Usage

This would typically be called inside the module implementation of on_runtime_upgrade, while ensuring no usage of this storage are made before the call to on_runtime_upgrade. (More precisely prior initialized modules doesn’t make use of this storage).

source

pub fn put<Arg>(val: Arg)
where Arg: EncodeLike<Value>,

Store a value under this key into the provided storage instance.

source

pub fn set(val: <QueryKind as QueryKindTrait<Value, OnEmpty>>::Query)

Store a value under this key into the provided storage instance.

this uses the query type rather than the underlying value.

source

pub fn mutate<R, F>(f: F) -> R
where F: FnOnce(&mut <QueryKind as QueryKindTrait<Value, OnEmpty>>::Query) -> R,

Mutate the value

source

pub fn mutate_extant<R, F>(f: F) -> R
where R: Default, F: FnOnce(&mut Value) -> R,

Mutate the value under a key iff it exists. Do nothing and return the default value if not.

source

pub fn try_mutate<R, E, F>(f: F) -> Result<R, E>
where F: FnOnce(&mut <QueryKind as QueryKindTrait<Value, OnEmpty>>::Query) -> Result<R, E>,

Mutate the value if closure returns Ok

source

pub fn mutate_exists<R, F>(f: F) -> R
where F: FnOnce(&mut Option<Value>) -> R,

Mutate the value. Deletes the item if mutated to a None.

source

pub fn try_mutate_exists<R, E, F>(f: F) -> Result<R, E>
where F: FnOnce(&mut Option<Value>) -> Result<R, E>,

Mutate the value if closure returns Ok. Deletes the item if mutated to a None.

source

pub fn kill()

Clear the storage value.

source

pub fn take() -> <QueryKind as QueryKindTrait<Value, OnEmpty>>::Query

Take a value from storage, removing it afterwards.

source

pub fn append<Item, EncodeLikeItem>(item: EncodeLikeItem)
where Item: Encode, EncodeLikeItem: EncodeLike<Item>, Value: StorageAppend<Item>,

Append the given item to the value in the storage.

Value is required to implement StorageAppend.

§Warning

If the storage item is not encoded properly, the storage item will be overwritten and set to [item]. Any default value set for the storage item will be ignored on overwrite.

source

pub fn decode_len() -> Option<usize>
where Value: StorageDecodeLength,

Read the length of the storage value without decoding the entire value.

Value is required to implement StorageDecodeLength.

If the value does not exists or it fails to decode the length, None is returned. Otherwise Some(len) is returned.

§Warning

None does not mean that get() does not return a value. The default value is completely ignored by this function.

source

pub fn decode_non_dedup_len() -> Option<usize>

Read the length of the storage value without decoding the entire value.

Value is required to implement StorageDecodeNonDedupLength.

If the value does not exists or it fails to decode the length, None is returned. Otherwise Some(len) is returned.

§Warning
  • None does not mean that get() does not return a value. The default value is completely ignored by this function.

  • The value returned is the non-deduplicated length of the underlying Vector in storage.This means that any duplicate items are included.

source

pub fn try_append<Item, EncodeLikeItem>(item: EncodeLikeItem) -> Result<(), ()>
where Item: Encode, EncodeLikeItem: EncodeLike<Item>, Value: StorageTryAppend<Item>,

Try and append the given item to the value in the storage.

Is only available if Value of the storage implements StorageTryAppend.

Trait Implementations

source§

impl<Prefix, Value, QueryKind, OnEmpty> PartialStorageInfoTrait for StorageValue<Prefix, Value, QueryKind, OnEmpty>
where Prefix: StorageInstance, Value: FullCodec, QueryKind: QueryKindTrait<Value, OnEmpty>, OnEmpty: Get<<QueryKind as QueryKindTrait<Value, OnEmpty>>::Query> + 'static,

It doesn’t require to implement MaxEncodedLen and give no information for max_size.

source§

impl<Prefix, Value, QueryKind, OnEmpty> StorageEntryMetadataBuilder for StorageValue<Prefix, Value, QueryKind, OnEmpty>
where Prefix: StorageInstance, Value: FullCodec + StaticTypeInfo, QueryKind: QueryKindTrait<Value, OnEmpty>, OnEmpty: Get<<QueryKind as QueryKindTrait<Value, OnEmpty>>::Query> + 'static,

source§

fn build_metadata( deprecation_status: DeprecationStatusIR, docs: Vec<&'static str>, entries: &mut Vec<StorageEntryMetadataIR>, )

Build into entries the storage metadata entries of a storage given some docs.
source§

impl<Prefix, Value, QueryKind, OnEmpty> StorageInfoTrait for StorageValue<Prefix, Value, QueryKind, OnEmpty>
where Prefix: StorageInstance, Value: FullCodec + MaxEncodedLen, QueryKind: QueryKindTrait<Value, OnEmpty>, OnEmpty: Get<<QueryKind as QueryKindTrait<Value, OnEmpty>>::Query> + 'static,

source§

impl<Prefix, Value, QueryKind, OnEmpty> TryDecodeEntireStorage for StorageValue<Prefix, Value, QueryKind, OnEmpty>
where Prefix: StorageInstance, Value: FullCodec, QueryKind: QueryKindTrait<Value, OnEmpty>, OnEmpty: Get<<QueryKind as QueryKindTrait<Value, OnEmpty>>::Query> + 'static,

source§

fn try_decode_entire_state() -> Result<usize, Vec<TryDecodeEntireStorageError>>

Decode the entire data under the given storage, returning Ok(bytes_decoded) if success.