Make use of assimilate_storage for GenesisConfig (#1982)

* Make use of `assimilate_storage` for `GenesisConfig`

Fixes incorrect initialization of the staking gensis storage.

* Add some documentation
This commit is contained in:
Bastian Köcher
2019-03-13 12:59:07 +01:00
committed by GitHub
parent e91426ac77
commit 17f093da13
8 changed files with 35 additions and 50 deletions
+1 -22
View File
@@ -106,14 +106,7 @@ pub trait BuildStorage: Sized {
Ok((storage, child_storage))
}
/// Assimilate the storage for this module into pre-existing overlays.
fn assimilate_storage(self, storage: &mut StorageOverlay, child_storage: &mut ChildrenStorageOverlay) -> Result<(), String> {
let (s, cs) = self.build_storage()?;
storage.extend(s);
for (other_child_key, other_child_map) in cs {
child_storage.entry(other_child_key).or_default().extend(other_child_map);
}
Ok(())
}
fn assimilate_storage(self, storage: &mut StorageOverlay, child_storage: &mut ChildrenStorageOverlay) -> Result<(), String>;
}
#[cfg(feature = "std")]
@@ -429,20 +422,6 @@ macro_rules! impl_outer_config {
)*
Ok(())
}
fn build_storage(self) -> ::std::result::Result<($crate::StorageOverlay, $crate::ChildrenStorageOverlay), String> {
let mut top = $crate::StorageOverlay::new();
let mut children = $crate::ChildrenStorageOverlay::new();
$(
if let Some(extra) = self.$snake {
let (other_top, other_children) = extra.build_storage()?;
top.extend(other_top);
for (other_child_key, other_child_map) in other_children {
children.entry(other_child_key).or_default().extend(other_child_map);
}
}
)*
Ok((top, children))
}
}
}
}