mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 13:57:58 +00:00
contracts: Don't read the previous value when overwriting a storage item (#7879)
* Add `len` function that can return the length of a storage item efficiently * Make use of the new len function in contracts * Fix benchmarks * cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_contracts --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/contracts/src/weights.rs --template=./.maintain/frame-weight-template.hbs * Remove unused imports Co-authored-by: Parity Benchmarking Bot <admin@parity.io>
This commit is contained in:
committed by
GitHub
parent
4678da3efb
commit
19e58df126
@@ -243,3 +243,21 @@ pub fn root(
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
/// Return the length in bytes of the value without reading it. `None` if it does not exist.
|
||||
pub fn len(
|
||||
child_info: &ChildInfo,
|
||||
key: &[u8],
|
||||
) -> Option<u32> {
|
||||
match child_info.child_type() {
|
||||
ChildType::ParentKeyId => {
|
||||
let mut buffer = [0; 0];
|
||||
sp_io::default_child_storage::read(
|
||||
child_info.storage_key(),
|
||||
key,
|
||||
&mut buffer,
|
||||
0,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user