pub trait StoragePrefixedMap<Value: FullCodec> {
    fn module_prefix() -> &'static [u8] ;
    fn storage_prefix() -> &'static [u8] ;

    fn final_prefix() -> [u8; 32] { ... }
    fn remove_all(limit: Option<u32>) -> KillStorageResult { ... }
    fn clear(limit: u32, maybe_cursor: Option<&[u8]>) -> MultiRemovalResults { ... }
    fn iter_values() -> PrefixIterator<Value>  { ... }
    fn translate_values<OldValue: Decode, F: FnMut(OldValue) -> Option<Value>>(
        f: F
    ) { ... } }
Expand description

Trait for maps that store all its value after a unique prefix.

By default the final prefix is:

Twox128(module_prefix) ++ Twox128(storage_prefix)

Required Methods

Module prefix. Used for generating final key.

Storage prefix. Used for generating final key.

Provided Methods

Final full prefix that prefixes all keys.

👎Deprecated: Use clear instead

Remove all values in the overlay and up to limit in the backend.

All values in the client overlay will be deleted, if there is some limit then up to limit values are deleted from the client backend, if limit is none then all values in the client backend are deleted.


Calling this multiple times per block with a limit set leads always to the same keys being removed and the same result being returned. This happens because the keys to delete in the overlay are not taken into account when deleting keys in the backend.

Attempt to remove all items from the map.

Returns MultiRemovalResults to inform about the result. Once the resultant maybe_cursor field is None, then no further items remain to be deleted.

NOTE: After the initial call for any given map, it is important that no further items are inserted into the map. If so, then the map may not be empty when the resultant maybe_cursor is None.


A limit must always be provided through in order to cap the maximum amount of deletions done in a single call. This is one fewer than the maximum number of backend iterations which may be done by this operation and as such represents the maximum number of backend deletions which may happen. A limit of zero implies that no keys will be deleted, though there may be a single iteration done.


A cursor may be passed in to this operation with maybe_cursor. None should only be passed once (in the initial call) for any given storage map. Subsequent calls operating on the same map should always pass Some, and this should be equal to the previous call result’s maybe_cursor field.

Iter over all value of the storage.

NOTE: If a value failed to decode because storage is corrupted then it is skipped.

Translate the values of all elements by a function f, in the map in no particular order. By returning None from f for an element, you’ll remove it from the map.

NOTE: If a value fail to decode because storage is corrupted then it is skipped.


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.


This would typically be called inside the module implementation of on_runtime_upgrade.