mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-12 04:05:42 +00:00
Child trie api changes BREAKING (#4857)
Co-Authored-By: thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
@@ -128,7 +128,7 @@ impl<T: Trait> AccountDb<T> for DirectAccountDb {
|
||||
trie_id: Option<&TrieId>,
|
||||
location: &StorageKey
|
||||
) -> Option<Vec<u8>> {
|
||||
trie_id.and_then(|id| child::get_raw(id, crate::trie_unique_id(&id[..]), &blake2_256(location)))
|
||||
trie_id.and_then(|id| child::get_raw(&crate::child_trie_info(&id[..]), &blake2_256(location)))
|
||||
}
|
||||
fn get_code_hash(&self, account: &T::AccountId) -> Option<CodeHash<T>> {
|
||||
<ContractInfoOf<T>>::get(account).and_then(|i| i.as_alive().map(|i| i.code_hash))
|
||||
@@ -167,13 +167,13 @@ impl<T: Trait> AccountDb<T> for DirectAccountDb {
|
||||
(false, Some(info), _) => info,
|
||||
// Existing contract is being removed.
|
||||
(true, Some(info), None) => {
|
||||
child::kill_storage(&info.trie_id, info.child_trie_unique_id());
|
||||
child::kill_storage(&info.child_trie_info());
|
||||
<ContractInfoOf<T>>::remove(&address);
|
||||
continue;
|
||||
}
|
||||
// Existing contract is being replaced by a new one.
|
||||
(true, Some(info), Some(code_hash)) => {
|
||||
child::kill_storage(&info.trie_id, info.child_trie_unique_id());
|
||||
child::kill_storage(&info.child_trie_info());
|
||||
AliveContractInfo::<T> {
|
||||
code_hash,
|
||||
storage_size: T::StorageSizeOffset::get(),
|
||||
@@ -212,17 +212,16 @@ impl<T: Trait> AccountDb<T> for DirectAccountDb {
|
||||
|
||||
for (k, v) in changed.storage.into_iter() {
|
||||
if let Some(value) = child::get_raw(
|
||||
&new_info.trie_id[..],
|
||||
new_info.child_trie_unique_id(),
|
||||
&new_info.child_trie_info(),
|
||||
&blake2_256(&k),
|
||||
) {
|
||||
new_info.storage_size -= value.len() as u32;
|
||||
}
|
||||
if let Some(value) = v {
|
||||
new_info.storage_size += value.len() as u32;
|
||||
child::put_raw(&new_info.trie_id[..], new_info.child_trie_unique_id(), &blake2_256(&k), &value[..]);
|
||||
child::put_raw(&new_info.child_trie_info(), &blake2_256(&k), &value[..]);
|
||||
} else {
|
||||
child::kill(&new_info.trie_id[..], new_info.child_trie_unique_id(), &blake2_256(&k));
|
||||
child::kill(&new_info.child_trie_info(), &blake2_256(&k));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user