-
Notifications
You must be signed in to change notification settings - Fork 2.7k
implemented contains_prefix for StorageDoubleMap and StorageNMap
#13232
Changes from all commits
b26116e
6fb5d13
5c1a057
5e32f06
f24a0ed
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 |
|---|---|---|
|
|
@@ -154,6 +154,16 @@ pub fn clear_prefix( | |
| MultiRemovalResults { maybe_cursor, backend: i, unique: i, loops: i } | ||
| } | ||
|
|
||
| /// Returns `true` if the storage contains any key, which starts with a certain prefix, | ||
| /// and is longer than said prefix. | ||
| /// This means that a key which equals the prefix will not be counted. | ||
| pub fn contains_prefixed_key(prefix: &[u8]) -> bool { | ||
|
Contributor
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. @cheme I hope this is fine now
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. 👍 (I am not really good at getting to the right api but looks fine, would have prefer a more explicit name as I never read the doc at first, but that's me :)
Contributor
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. just for some context, @shawntabrizi approved the api and doc 😺
Member
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. yes, if you look above, you will see a bunch of APIs for acting on one key, like |
||
| match sp_io::storage::next_key(prefix) { | ||
| Some(key) => key.starts_with(prefix), | ||
| None => false, | ||
| } | ||
| } | ||
|
|
||
| /// Get a Vec of bytes from storage. | ||
| pub fn get_raw(key: &[u8]) -> Option<Vec<u8>> { | ||
| sp_io::storage::get(key).map(|value| value.to_vec()) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.