mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-01 11:17:56 +00:00
Prevent double allocation of the payload when calling sp_io::storage::get (#11523)
* Expose allocation stats in `FreeingBumpHeapAllocator` * Return allocation stats when calling into the runtime * Bump `parity-scale-codec` to 3.1.3 (fork) * Prevent double allocation of the payload when calling `sp_io::storage::get` * Fix tests * Remove unnecessary `mut` * Enable the `bytes` feature for `parity-scale-codec` in `sp-runtime-interface` * Update client/allocator/src/freeing_bump.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Bump `parity-scale-codec` to 3.1.3 * Fix some of the UI tests Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -125,8 +125,8 @@ impl From<MultiRemovalResults> for KillStorageResult {
|
||||
#[runtime_interface]
|
||||
pub trait Storage {
|
||||
/// Returns the data for `key` in the storage or `None` if the key can not be found.
|
||||
fn get(&self, key: &[u8]) -> Option<Vec<u8>> {
|
||||
self.storage(key).map(|s| s.to_vec())
|
||||
fn get(&self, key: &[u8]) -> Option<bytes::Bytes> {
|
||||
self.storage(key).map(|s| bytes::Bytes::from(s.to_vec()))
|
||||
}
|
||||
|
||||
/// Get `key` from storage, placing the value into `value_out` and return the number of
|
||||
@@ -1787,7 +1787,7 @@ mod tests {
|
||||
t.execute_with(|| {
|
||||
assert_eq!(storage::get(b"hello"), None);
|
||||
storage::set(b"hello", b"world");
|
||||
assert_eq!(storage::get(b"hello"), Some(b"world".to_vec()));
|
||||
assert_eq!(storage::get(b"hello"), Some(b"world".to_vec().into()));
|
||||
assert_eq!(storage::get(b"foo"), None);
|
||||
storage::set(b"foo", &[1, 2, 3][..]);
|
||||
});
|
||||
@@ -1799,7 +1799,7 @@ mod tests {
|
||||
|
||||
t.execute_with(|| {
|
||||
assert_eq!(storage::get(b"hello"), None);
|
||||
assert_eq!(storage::get(b"foo"), Some(b"bar".to_vec()));
|
||||
assert_eq!(storage::get(b"foo"), Some(b"bar".to_vec().into()));
|
||||
});
|
||||
|
||||
let value = vec![7u8; 35];
|
||||
@@ -1809,7 +1809,7 @@ mod tests {
|
||||
|
||||
t.execute_with(|| {
|
||||
assert_eq!(storage::get(b"hello"), None);
|
||||
assert_eq!(storage::get(b"foo00"), Some(value.clone()));
|
||||
assert_eq!(storage::get(b"foo00"), Some(value.clone().into()));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user