Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
match prefix to next_key
Browse files Browse the repository at this point in the history
Signed-off-by: muraca <mmuraca247@gmail.com>
  • Loading branch information
muraca committed Jan 25, 2023
1 parent b26116e commit 6fb5d13
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions frame/support/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1792,6 +1792,7 @@ mod test {
assert_eq!(FooDoubleMap::contains_prefix(0), false);

assert_ok!(FooDoubleMap::try_append(1, 1, 4));
assert_ok!(FooDoubleMap::try_append(2, 1, 4));
assert!(FooDoubleMap::iter_prefix_values(1).next().is_some());
assert!(FooDoubleMap::contains_prefix(1));
FooDoubleMap::remove(1, 1);
Expand Down
5 changes: 4 additions & 1 deletion frame/support/src/storage/unhashed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ pub fn clear_prefix(
}

pub fn contains_prefix(prefix: &[u8]) -> bool {
sp_io::storage::next_key(prefix).is_some()
match sp_io::storage::next_key(prefix) {
Some(key) => key.starts_with(prefix),
None => false,
}
}

/// Get a Vec of bytes from storage.
Expand Down

0 comments on commit 6fb5d13

Please sign in to comment.