pub fn clear_prefix(prefix: &[u8], limit: Option<u32>) -> KillStorageResult
Expand description

Clear the storage of each key-value pair where the key starts with the given prefix.

Limit

Deletes all keys from the overlay and up to limit keys from the backend if it is set to Some. No limit is applied when limit is set to None.

The limit can be used to partially delete a prefix storage in case it is too large to delete in one go (block).

It returns a boolean false iff some keys are remaining in the prefix after the functions returns. Also returns a u32 with the number of keys removed from the process.

Note

Please note that keys that are residing in the overlay for that prefix when issuing this call are all deleted without counting towards the limit. Only keys written during the current block are part of the overlay. Deleting with a limit mostly makes sense with an empty overlay for that prefix.

Calling this function multiple times per block for the same prefix does not make much sense because it is not cumulative when called inside the same block. Use this function to distribute the deletion of a single child trie across multiple blocks.