mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 13:31:10 +00:00
Optimize decode_len (#5975)
* Optimize `decode_len` Instead of reading the full storage value into the runtime, we only read at maximum `5bytes` from the storage into the runtime. Furthermore this drops any handling with regards to set default values in `decl_storage!`. If the value does not exists or the decoding of the length fails, it will return `None`. To prevent people from messing stuff up, this feature relies on the `StorageDecodeLength` trait that is sealed by `frame-support` (aka only implementable inside this crate). * Some clean ups * Update frame/support/src/storage/mod.rs Co-authored-by: Alexander Popiak <alexander.popiak@parity.io> Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
This commit is contained in:
@@ -2337,7 +2337,7 @@ impl<T: Trait> Module<T> {
|
||||
// that we need. Then it should be Self::validator_count(). Else it should be all the
|
||||
// candidates.
|
||||
let snapshot_length = <SnapshotValidators<T>>::decode_len()
|
||||
.map_err(|_| Error::<T>::SnapshotUnavailable)?;
|
||||
.ok_or_else(|| Error::<T>::SnapshotUnavailable)?;
|
||||
|
||||
// check the winner length only here and when we know the length of the snapshot validators
|
||||
// length.
|
||||
|
||||
Reference in New Issue
Block a user