Add missing child trie rpc on_custom_message handler (#3522)

* missing on_custom for child read.

* fix and complete, add test cases.

* shorten line.

* replace vecs of key value tuple with maps.
This commit is contained in:
cheme authored and Gavin Wood committed 2019-08-31 17:19:54 -07:00
1 parent 63c15c9803
commit 816e132cd7
7 files changed
+167 -14

No files matched your search

@@ -30,7 +30,8 @@ pub struct GenesisConfig {
balances: Vec<(AccountId, u64)>,
heap_pages_override: Option<u64>,
/// Additional storage key pairs that will be added to the genesis map.
extra_storage: Vec<(Vec<u8>, Vec<u8>)>,
extra_storage: HashMap<Vec<u8>, Vec<u8>>,
child_extra_storage: HashMap<Vec<u8>, HashMap<Vec<u8>, Vec<u8>>>,
}
impl GenesisConfig {
@@ -40,7 +41,8 @@ impl GenesisConfig {
endowed_accounts: Vec<AccountId>,
balance: u64,
heap_pages_override: Option<u64>,
extra_storage: Vec<(Vec<u8>, Vec<u8>)>,
extra_storage: HashMap<Vec<u8>, Vec<u8>>,
child_extra_storage: HashMap<Vec<u8>, HashMap<Vec<u8>, Vec<u8>>>,
) -> Self {
GenesisConfig {
changes_trie_config: match support_changes_trie {
@@ -51,6 +53,7 @@ impl GenesisConfig {
balances: endowed_accounts.into_iter().map(|a| (a, balance)).collect(),
heap_pages_override,
extra_storage,
child_extra_storage,
}
}
@@ -75,10 +78,9 @@ impl GenesisConfig {
}
map.insert(twox_128(&b"sys:auth"[..])[..].to_vec(), self.authorities.encode());
// Finally, add the extra storage entries.
for (key, value) in self.extra_storage.iter().cloned() {
map.insert(key, value);
}
(map, Default::default())
map.extend(self.extra_storage.clone().into_iter());
(map, self.child_extra_storage.clone())
}
}