Implement a CountedStorageMap (#9125)

* initial impl

* expose in pallet_prelude

* temp test

* Apply suggestions from code review

Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>
Co-authored-by: Xiliang Chen <xlchen1291@gmail.com>

* implement with macro help.

* test for macro generation

* add iterable functions, some test and fixes

* fix merge

* doc

* Update frame/support/src/storage/types/counted_map.rs

Co-authored-by: Zeke Mostov <32168567+emostov@users.noreply.github.com>

* fix merge

* fmt

* fix spelling

* improve on removal

* fix partial storage info

* fmt

* add license

* suggested renames

* fix typo

* fix test

* fmt

* fix ui tests

* clearer doc

* better doc

* add metadata test

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>
Co-authored-by: Xiliang Chen <xlchen1291@gmail.com>
Co-authored-by: Zeke Mostov <32168567+emostov@users.noreply.github.com>
This commit is contained in:
Guillaume Thiolliere
2021-09-16 15:20:29 +02:00
committed by GitHub
parent 49b6dfd2e5
commit 65e5fa3aa3
22 changed files with 1721 additions and 204 deletions
@@ -219,6 +219,7 @@ where
previous_key: prefix,
drain: false,
closure: |_raw_key, mut raw_value| V::decode(&mut raw_value),
phantom: Default::default(),
}
}
@@ -345,6 +346,7 @@ where
let mut key_material = G::Hasher2::reverse(raw_key_without_prefix);
Ok((K2::decode(&mut key_material)?, V::decode(&mut raw_value)?))
},
phantom: Default::default(),
}
}
@@ -398,6 +400,7 @@ where
let k2 = K2::decode(&mut k2_material)?;
Ok((k1, k2, V::decode(&mut raw_value)?))
},
phantom: Default::default(),
}
}
@@ -138,6 +138,7 @@ where
let mut key_material = G::Hasher::reverse(raw_key_without_prefix);
Ok((K::decode(&mut key_material)?, V::decode(&mut raw_value)?))
},
phantom: Default::default(),
}
}
@@ -196,6 +196,7 @@ where
previous_key: prefix,
drain: false,
closure: |_raw_key, mut raw_value| V::decode(&mut raw_value),
phantom: Default::default(),
}
}
@@ -305,6 +306,7 @@ impl<K: ReversibleKeyGenerator, V: FullCodec, G: StorageNMap<K, V>>
let partial_key = K::decode_partial_key(raw_key_without_prefix)?;
Ok((partial_key, V::decode(&mut raw_value)?))
},
phantom: Default::default(),
}
}
@@ -368,6 +370,7 @@ impl<K: ReversibleKeyGenerator, V: FullCodec, G: StorageNMap<K, V>>
let (final_key, _) = K::decode_final_key(raw_key_without_prefix)?;
Ok((final_key, V::decode(&mut raw_value)?))
},
phantom: Default::default(),
}
}