mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-08 20:38:04 +00:00
Less slices (#9176)
* Less slices Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -207,7 +207,7 @@ pub trait Backend<H: Hasher>: sp_std::fmt::Debug {
|
||||
}
|
||||
}
|
||||
let (root, parent_txs) = self.storage_root(delta
|
||||
.map(|(k, v)| (&k[..], v.as_ref().map(|v| &v[..])))
|
||||
.map(|(k, v)| (k, v.as_ref().map(|v| &v[..])))
|
||||
.chain(
|
||||
child_roots
|
||||
.iter()
|
||||
|
||||
@@ -279,22 +279,22 @@ fn prepare_digest_input<'a, H, Number>(
|
||||
trie_root,
|
||||
);
|
||||
|
||||
trie_storage.for_key_values_with_prefix(&child_prefix, |key, value|
|
||||
if let Ok(InputKey::ChildIndex::<Number>(trie_key)) = Decode::decode(&mut &key[..]) {
|
||||
if let Ok(value) = <Vec<u8>>::decode(&mut &value[..]) {
|
||||
trie_storage.for_key_values_with_prefix(&child_prefix, |mut key, mut value|
|
||||
if let Ok(InputKey::ChildIndex::<Number>(trie_key)) = Decode::decode(&mut key) {
|
||||
if let Ok(value) = <Vec<u8>>::decode(&mut value) {
|
||||
let mut trie_root = <H as Hasher>::Out::default();
|
||||
trie_root.as_mut().copy_from_slice(&value[..]);
|
||||
children_roots.insert(trie_key.storage_key, trie_root);
|
||||
}
|
||||
});
|
||||
|
||||
trie_storage.for_keys_with_prefix(&extrinsic_prefix, |key|
|
||||
if let Ok(InputKey::ExtrinsicIndex::<Number>(trie_key)) = Decode::decode(&mut &key[..]) {
|
||||
trie_storage.for_keys_with_prefix(&extrinsic_prefix, |mut key|
|
||||
if let Ok(InputKey::ExtrinsicIndex::<Number>(trie_key)) = Decode::decode(&mut key) {
|
||||
insert_to_map(&mut map, trie_key.key);
|
||||
});
|
||||
|
||||
trie_storage.for_keys_with_prefix(&digest_prefix, |key|
|
||||
if let Ok(InputKey::DigestIndex::<Number>(trie_key)) = Decode::decode(&mut &key[..]) {
|
||||
trie_storage.for_keys_with_prefix(&digest_prefix, |mut key|
|
||||
if let Ok(InputKey::DigestIndex::<Number>(trie_key)) = Decode::decode(&mut key) {
|
||||
insert_to_map(&mut map, trie_key.key);
|
||||
});
|
||||
}
|
||||
@@ -310,13 +310,13 @@ fn prepare_digest_input<'a, H, Number>(
|
||||
crate::changes_trie::TrieBackendStorageAdapter(storage),
|
||||
trie_root,
|
||||
);
|
||||
trie_storage.for_keys_with_prefix(&extrinsic_prefix, |key|
|
||||
if let Ok(InputKey::ExtrinsicIndex::<Number>(trie_key)) = Decode::decode(&mut &key[..]) {
|
||||
trie_storage.for_keys_with_prefix(&extrinsic_prefix, |mut key|
|
||||
if let Ok(InputKey::ExtrinsicIndex::<Number>(trie_key)) = Decode::decode(&mut key) {
|
||||
insert_to_map(&mut map, trie_key.key);
|
||||
});
|
||||
|
||||
trie_storage.for_keys_with_prefix(&digest_prefix, |key|
|
||||
if let Ok(InputKey::DigestIndex::<Number>(trie_key)) = Decode::decode(&mut &key[..]) {
|
||||
trie_storage.for_keys_with_prefix(&digest_prefix, |mut key|
|
||||
if let Ok(InputKey::DigestIndex::<Number>(trie_key)) = Decode::decode(&mut key) {
|
||||
insert_to_map(&mut map, trie_key.key);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -66,9 +66,9 @@ pub fn prune<H: Hasher, Number: BlockNumber, F: FnMut(H::Out)>(
|
||||
);
|
||||
let child_prefix = ChildIndex::key_neutral_prefix(block.clone());
|
||||
let mut children_roots = Vec::new();
|
||||
trie_storage.for_key_values_with_prefix(&child_prefix, |key, value| {
|
||||
if let Ok(InputKey::ChildIndex::<Number>(_trie_key)) = Decode::decode(&mut &key[..]) {
|
||||
if let Ok(value) = <Vec<u8>>::decode(&mut &value[..]) {
|
||||
trie_storage.for_key_values_with_prefix(&child_prefix, |mut key, mut value| {
|
||||
if let Ok(InputKey::ChildIndex::<Number>(_trie_key)) = Decode::decode(&mut key) {
|
||||
if let Ok(value) = <Vec<u8>>::decode(&mut value) {
|
||||
let mut trie_root = <H as Hasher>::Out::default();
|
||||
trie_root.as_mut().copy_from_slice(&value[..]);
|
||||
children_roots.push(trie_root);
|
||||
|
||||
@@ -637,7 +637,7 @@ where
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
fn storage_changes_root(&mut self, parent_hash: &[u8]) -> Result<Option<Vec<u8>>, ()> {
|
||||
fn storage_changes_root(&mut self, mut parent_hash: &[u8]) -> Result<Option<Vec<u8>>, ()> {
|
||||
let _guard = guard();
|
||||
if let Some(ref root) = self.storage_transaction_cache.changes_trie_transaction_storage_root {
|
||||
trace!(
|
||||
@@ -653,7 +653,7 @@ where
|
||||
let root = self.overlay.changes_trie_root(
|
||||
self.backend,
|
||||
self.changes_trie_state.as_ref(),
|
||||
Decode::decode(&mut &parent_hash[..]).map_err(|e|
|
||||
Decode::decode(&mut parent_hash).map_err(|e|
|
||||
trace!(
|
||||
target: "state",
|
||||
"Failed to decode changes root parent hash: {}",
|
||||
|
||||
Reference in New Issue
Block a user