Add methods to PrefixIterator to support iterating from a specific key (#9313)

* Add methods to PrefixIterator to support iterating from a specific key

* Expose the decode functions used in iterators for storage maps

* Use associated decode function in tests

* Revert "Expose the decode functions used in iterators for storage maps"

This reverts commit 34f57d92db89646d0c98ea1880df58d58e523b09.

* Fix documentation for next_key

* Add API for iterating from a specified key for all storage map types

* Enhance pagination test

* Add API methods to storage map types

* Rename next_key to last_key

* Rename last_key to last_raw_key

* Specify that iteration starts after starting_raw_key

* Update documentation on iteration ordering

* Rename next_key to previous_key

* Enhance pagination unit test

* Create unit tests for all kinds of iter_from methods

* Define iter_from in terms of iter rather than vice versa

* Cargo fmt
This commit is contained in:
Keith Yeung
2021-07-26 17:43:15 -07:00
committed by GitHub
parent 492523f1ae
commit 845e6a5ff1
9 changed files with 535 additions and 46 deletions
+1 -1
View File
@@ -163,7 +163,7 @@ macro_rules! generate_storage_alias {
>;
}
};
($pallet:ident, $name:ident => NMap<$(($key:ty, $hasher:ty),)+ $value:ty>) => {
($pallet:ident, $name:ident => NMap<Key<$(($key:ty, $hasher:ty)),+>, $value:ty>) => {
$crate::paste::paste! {
$crate::generate_storage_alias!(@GENERATE_INSTANCE_STRUCT $pallet, $name);
type $name = $crate::storage::types::StorageNMap<