-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Improve docs of remove_all and remove_prefix
#11182
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -173,7 +173,18 @@ where | |
| <Self as crate::storage::StorageNMap<Key, Value>>::remove(key) | ||
| } | ||
|
|
||
| /// Remove all values under the first key. | ||
| /// Remove all values starting with `partial_key` 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. | ||
| /// | ||
| /// # Note | ||
| /// | ||
| /// 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. | ||
| pub fn remove_prefix<KP>(partial_key: KP, limit: Option<u32>) -> sp_io::KillStorageResult | ||
| where | ||
| Key: HasKeyPrefix<KP>, | ||
|
|
@@ -277,7 +288,17 @@ where | |
| <Self as crate::storage::StorageNMap<Key, Value>>::migrate_keys::<_>(key, hash_fns) | ||
| } | ||
|
|
||
| /// Remove all value of the storage. | ||
| /// 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. | ||
| /// | ||
| /// # Note | ||
| /// | ||
| /// 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. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then Note is more about the underlying reason (no persistence of the applied limit in the overlay). Wonder if renaming
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually I like your comment on sp-io better.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Which part exactly? Could you add some suggestions to the pr?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The note that describe the way overlay is handled: Is more clear to me, but that may be because I know the problematic.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Talked to @shawntabrizi and he said we can continue with the current docs. |
||
| pub fn remove_all(limit: Option<u32>) -> sp_io::KillStorageResult { | ||
| <Self as crate::storage::StoragePrefixedMap<Value>>::remove_all(limit) | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could add
For multiple calls the largest limit is applied.