mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 04:01:10 +00:00
Frame remove_all with size limit. (#9106)
* remove prefixed content with limit. * test match * factor comment and factor ext limit removal. * fix benchmark Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
@@ -373,13 +373,14 @@ impl<B: BlockT> StateBackend<HashFor<B>> for BenchmarkingState<B> {
|
||||
}
|
||||
}
|
||||
|
||||
fn apply_to_child_keys_while<F: FnMut(&[u8]) -> bool>(
|
||||
fn apply_to_keys_while<F: FnMut(&[u8]) -> bool>(
|
||||
&self,
|
||||
child_info: &ChildInfo,
|
||||
child_info: Option<&ChildInfo>,
|
||||
prefix: Option<&[u8]>,
|
||||
f: F,
|
||||
) {
|
||||
if let Some(ref state) = *self.state.borrow() {
|
||||
state.apply_to_child_keys_while(child_info, f)
|
||||
state.apply_to_keys_while(child_info, prefix, f)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -205,12 +205,13 @@ impl<B: BlockT> StateBackend<HashFor<B>> for RefTrackingState<B> {
|
||||
self.state.for_key_values_with_prefix(prefix, f)
|
||||
}
|
||||
|
||||
fn apply_to_child_keys_while<F: FnMut(&[u8]) -> bool>(
|
||||
fn apply_to_keys_while<F: FnMut(&[u8]) -> bool>(
|
||||
&self,
|
||||
child_info: &ChildInfo,
|
||||
child_info: Option<&ChildInfo>,
|
||||
prefix: Option<&[u8]>,
|
||||
f: F,
|
||||
) {
|
||||
self.state.apply_to_child_keys_while(child_info, f)
|
||||
self.state.apply_to_keys_while(child_info, prefix, f)
|
||||
}
|
||||
|
||||
fn for_child_keys_with_prefix<F: FnMut(&[u8])>(
|
||||
|
||||
@@ -605,12 +605,13 @@ impl<S: StateBackend<HashFor<B>>, B: BlockT> StateBackend<HashFor<B>> for Cachin
|
||||
self.state.exists_child_storage(child_info, key)
|
||||
}
|
||||
|
||||
fn apply_to_child_keys_while<F: FnMut(&[u8]) -> bool>(
|
||||
fn apply_to_keys_while<F: FnMut(&[u8]) -> bool>(
|
||||
&self,
|
||||
child_info: &ChildInfo,
|
||||
child_info: Option<&ChildInfo>,
|
||||
prefix: Option<&[u8]>,
|
||||
f: F,
|
||||
) {
|
||||
self.state.apply_to_child_keys_while(child_info, f)
|
||||
self.state.apply_to_keys_while(child_info, prefix, f)
|
||||
}
|
||||
|
||||
fn next_storage_key(&self, key: &[u8]) -> Result<Option<Vec<u8>>, Self::Error> {
|
||||
@@ -787,12 +788,13 @@ impl<S: StateBackend<HashFor<B>>, B: BlockT> StateBackend<HashFor<B>> for Syncin
|
||||
self.caching_state().exists_child_storage(child_info, key)
|
||||
}
|
||||
|
||||
fn apply_to_child_keys_while<F: FnMut(&[u8]) -> bool>(
|
||||
fn apply_to_keys_while<F: FnMut(&[u8]) -> bool>(
|
||||
&self,
|
||||
child_info: &ChildInfo,
|
||||
child_info: Option<&ChildInfo>,
|
||||
prefix: Option<&[u8]>,
|
||||
f: F,
|
||||
) {
|
||||
self.caching_state().apply_to_child_keys_while(child_info, f)
|
||||
self.caching_state().apply_to_keys_while(child_info, prefix, f)
|
||||
}
|
||||
|
||||
fn next_storage_key(&self, key: &[u8]) -> Result<Option<Vec<u8>>, Self::Error> {
|
||||
|
||||
@@ -71,7 +71,7 @@ sp_core::wasm_export_functions! {
|
||||
}
|
||||
|
||||
fn test_clear_prefix(input: Vec<u8>) -> Vec<u8> {
|
||||
storage::clear_prefix(&input);
|
||||
storage::clear_prefix(&input, None);
|
||||
b"all ok!".to_vec()
|
||||
}
|
||||
|
||||
|
||||
@@ -461,14 +461,15 @@ impl<H: Hasher> StateBackend<H> for GenesisOrUnavailableState<H>
|
||||
}
|
||||
}
|
||||
|
||||
fn apply_to_child_keys_while<A: FnMut(&[u8]) -> bool>(
|
||||
fn apply_to_keys_while<A: FnMut(&[u8]) -> bool>(
|
||||
&self,
|
||||
child_info: &ChildInfo,
|
||||
child_info: Option<&ChildInfo>,
|
||||
prefix: Option<&[u8]>,
|
||||
action: A,
|
||||
) {
|
||||
match *self {
|
||||
GenesisOrUnavailableState::Genesis(ref state) =>
|
||||
state.apply_to_child_keys_while(child_info, action),
|
||||
state.apply_to_keys_while(child_info, prefix, action),
|
||||
GenesisOrUnavailableState::Unavailable => (),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user