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,
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,
sourcepub fn hashed_key() -> [u8; 32]
pub fn hashed_key() -> [u8; 32]
Get the storage key.
sourcepub fn get() -> <QueryKind as QueryKindTrait<Value, OnEmpty>>::Query
pub fn get() -> <QueryKind as QueryKindTrait<Value, OnEmpty>>::Query
Load the value from the provided storage instance.
sourcepub fn try_get() -> Result<Value, ()>
pub fn try_get() -> Result<Value, ()>
Try to get the underlying value from the provided storage instance; Ok
if it exists,
Err
if not.
sourcepub fn translate<O, F>(f: F) -> Result<Option<Value>, ()>
pub fn translate<O, F>(f: F) -> Result<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).
sourcepub fn put<Arg>(val: Arg)where
Arg: EncodeLike<Value>,
pub fn put<Arg>(val: Arg)where
Arg: EncodeLike<Value>,
Store a value under this key into the provided storage instance.
sourcepub fn set(val: <QueryKind as QueryKindTrait<Value, OnEmpty>>::Query)
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.
sourcepub fn mutate_extant<R, F>(f: F) -> R
pub fn mutate_extant<R, F>(f: F) -> R
Mutate the value under a key iff it exists. Do nothing and return the default value if not.
sourcepub fn try_mutate<R, E, F>(f: F) -> Result<R, E>
pub fn try_mutate<R, E, F>(f: F) -> Result<R, E>
Mutate the value if closure returns Ok
sourcepub fn mutate_exists<R, F>(f: F) -> R
pub fn mutate_exists<R, F>(f: F) -> R
Mutate the value. Deletes the item if mutated to a None
.
sourcepub fn try_mutate_exists<R, E, F>(f: F) -> Result<R, E>
pub fn try_mutate_exists<R, E, F>(f: F) -> Result<R, E>
Mutate the value if closure returns Ok
. Deletes the item if mutated to a None
.
sourcepub fn take() -> <QueryKind as QueryKindTrait<Value, OnEmpty>>::Query
pub fn take() -> <QueryKind as QueryKindTrait<Value, OnEmpty>>::Query
Take a value from storage, removing it afterwards.
sourcepub fn append<Item, EncodeLikeItem>(item: EncodeLikeItem)
pub fn append<Item, EncodeLikeItem>(item: EncodeLikeItem)
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.
sourcepub fn decode_len() -> Option<usize>where
Value: StorageDecodeLength,
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.
sourcepub fn decode_non_dedup_len() -> Option<usize>where
Value: StorageDecodeNonDedupLength,
pub fn decode_non_dedup_len() -> Option<usize>where
Value: StorageDecodeNonDedupLength,
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 thatget()
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.
sourcepub fn try_append<Item, EncodeLikeItem>(item: EncodeLikeItem) -> Result<(), ()>
pub fn try_append<Item, EncodeLikeItem>(item: EncodeLikeItem) -> Result<(), ()>
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,
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
.
fn partial_storage_info() -> Vec<StorageInfo>
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,
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>,
)
fn build_metadata( deprecation_status: DeprecationStatusIR, docs: Vec<&'static str>, entries: &mut Vec<StorageEntryMetadataIR>, )
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,
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,
fn storage_info() -> Vec<StorageInfo>
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,
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>>
fn try_decode_entire_state() -> Result<usize, Vec<TryDecodeEntireStorageError>>
Ok(bytes_decoded)
if success.