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

Commit

Permalink
Use v2 for now
Browse files Browse the repository at this point in the history
  • Loading branch information
gavofyork committed May 20, 2022
1 parent aee7993 commit a1982d1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion frame/support/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ pub trait StoragePrefixedMap<Value: FullCodec> {
/// 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.
fn clear(limit: Option<u32>) -> sp_io::ClearPrefixResult {
sp_io::storage::clear_prefix(&Self::final_prefix(), limit)
unhashed::clear_prefix(&Self::final_prefix(), limit)
}

/// Iter over all value of the storage.
Expand Down
14 changes: 12 additions & 2 deletions frame/support/src/storage/unhashed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,22 @@ pub fn kill(key: &[u8]) {
/// Ensure keys with the given `prefix` have no entries in storage.
#[deprecated = "Use `clear_prefix` instead"]
pub fn kill_prefix(prefix: &[u8], limit: Option<u32>) -> sp_io::KillStorageResult {
clear_prefix(prefix, limit).into()
// TODO: Once the network has upgraded to include the new host functions, this code can be
// enabled.
// clear_prefix(prefix, limit).into()
sp_io::storage::clear_prefix(prefix, limit)
}

/// Ensure keys with the given `prefix` have no entries in storage.
pub fn clear_prefix(prefix: &[u8], limit: Option<u32>) -> sp_io::ClearPrefixResult {
sp_io::storage::clear_prefix(prefix, limit)
// TODO: Once the network has upgraded to include the new host functions, this code can be
// enabled.
// sp_io::storage::clear_prefix(prefix, limit)
use sp_io::{KillStorageResult::*, ClearPrefixResult::*};
match kill_prefix(prefix, limit) {
AllRemoved(db) => NoneLeft { db, total: db },
SomeRemaining(db) => SomeLeft { db, total: db },
}
}

/// Get a Vec of bytes from storage.
Expand Down
2 changes: 1 addition & 1 deletion primitives/io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ pub trait Storage {
/// every time this function is called with the exact same arguments per block. This happens
/// because the keys in the overlay are not taken into account when deleting keys in the
/// backend.
#[version(3)]
#[version(3, register_only)]
fn clear_prefix(&mut self, prefix: &[u8], limit: Option<u32>) -> ClearPrefixResult {
let (all_removed, db, total) = Externalities::clear_prefix(*self, prefix, limit);
match all_removed {
Expand Down

0 comments on commit a1982d1

Please sign in to comment.