frame_support::storage: Add StorageStreamIter (#12721)

* Save

* Add some test

* Yep

* Move to its own file

* More work

* More

* Finish implementation

* Start resolving comments and fixing bugs

* Fix all review comments

* Update frame/support/src/storage/stream_iter.rs

Co-authored-by: Koute <koute@users.noreply.github.com>

* Update frame/support/src/storage/stream_iter.rs

Co-authored-by: Koute <koute@users.noreply.github.com>

* Review feedback

* FMT

* Okay, let's initialize the values...

* Fix...

Co-authored-by: Koute <koute@users.noreply.github.com>
This commit is contained in:
Bastian Köcher
2022-12-17 10:07:23 +01:00
committed by GitHub
parent e876ed310e
commit 9a5f47962f
4 changed files with 676 additions and 6 deletions
@@ -23,12 +23,13 @@ use sp_std::prelude::*;
/// Return the value of the item in storage under `key`, or `None` if there is no explicit entry.
pub fn get<T: Decode + Sized>(key: &[u8]) -> Option<T> {
sp_io::storage::get(key).and_then(|val| {
Decode::decode(&mut &val[..]).map(Some).unwrap_or_else(|_| {
Decode::decode(&mut &val[..]).map(Some).unwrap_or_else(|e| {
// TODO #3700: error should be handleable.
log::error!(
target: "runtime::storage",
"Corrupted state at {:?}",
"Corrupted state at `{:?}: {:?}`",
key,
e,
);
None
})