mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 13:31:10 +00:00
Let StorageDoubleMap use borrowed key types (#1804)
* Let StorageDoubleMap use borrowed key types * Bump impl version
This commit is contained in:
committed by
Gav Wood
parent
4bf4b37185
commit
f5ab24804f
@@ -54,7 +54,7 @@ pub trait AccountDb<T: Trait> {
|
||||
pub struct DirectAccountDb;
|
||||
impl<T: Trait> AccountDb<T> for DirectAccountDb {
|
||||
fn get_storage(&self, account: &T::AccountId, location: &[u8]) -> Option<Vec<u8>> {
|
||||
<StorageOf<T>>::get(account.clone(), location.to_vec())
|
||||
<StorageOf<T>>::get(account, &location.to_vec())
|
||||
}
|
||||
fn get_code(&self, account: &T::AccountId) -> Option<CodeHash<T>> {
|
||||
<CodeHashOf<T>>::get(account)
|
||||
@@ -83,9 +83,9 @@ impl<T: Trait> AccountDb<T> for DirectAccountDb {
|
||||
}
|
||||
for (k, v) in changed.storage.into_iter() {
|
||||
if let Some(value) = v {
|
||||
<StorageOf<T>>::insert(address.clone(), k, value);
|
||||
<StorageOf<T>>::insert(&address, &k, value);
|
||||
} else {
|
||||
<StorageOf<T>>::remove(address.clone(), k);
|
||||
<StorageOf<T>>::remove(&address, &k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -369,7 +369,7 @@ impl<T: Trait> StorageDoubleMap for StorageOf<T> {
|
||||
impl<T: Trait> OnFreeBalanceZero<T::AccountId> for Module<T> {
|
||||
fn on_free_balance_zero(who: &T::AccountId) {
|
||||
<CodeHashOf<T>>::remove(who);
|
||||
<StorageOf<T>>::remove_prefix(who.clone());
|
||||
<StorageOf<T>>::remove_prefix(who);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -224,13 +224,13 @@ fn account_removal_removes_storage() {
|
||||
{
|
||||
Balances::set_free_balance(&1, 110);
|
||||
Balances::increase_total_stake_by(110);
|
||||
<StorageOf<Test>>::insert(1, b"foo".to_vec(), b"1".to_vec());
|
||||
<StorageOf<Test>>::insert(1, b"bar".to_vec(), b"2".to_vec());
|
||||
<StorageOf<Test>>::insert(&1, &b"foo".to_vec(), b"1".to_vec());
|
||||
<StorageOf<Test>>::insert(&1, &b"bar".to_vec(), b"2".to_vec());
|
||||
|
||||
Balances::set_free_balance(&2, 110);
|
||||
Balances::increase_total_stake_by(110);
|
||||
<StorageOf<Test>>::insert(2, b"hello".to_vec(), b"3".to_vec());
|
||||
<StorageOf<Test>>::insert(2, b"world".to_vec(), b"4".to_vec());
|
||||
<StorageOf<Test>>::insert(&2, &b"hello".to_vec(), b"3".to_vec());
|
||||
<StorageOf<Test>>::insert(&2, &b"world".to_vec(), b"4".to_vec());
|
||||
}
|
||||
|
||||
// Transfer funds from account 1 of such amount that after this transfer
|
||||
@@ -242,15 +242,15 @@ fn account_removal_removes_storage() {
|
||||
// Verify that all entries from account 1 is removed, while
|
||||
// entries from account 2 is in place.
|
||||
{
|
||||
assert_eq!(<StorageOf<Test>>::get(1, b"foo".to_vec()), None);
|
||||
assert_eq!(<StorageOf<Test>>::get(1, b"bar".to_vec()), None);
|
||||
assert_eq!(<StorageOf<Test>>::get(&1, &b"foo".to_vec()), None);
|
||||
assert_eq!(<StorageOf<Test>>::get(&1, &b"bar".to_vec()), None);
|
||||
|
||||
assert_eq!(
|
||||
<StorageOf<Test>>::get(2, b"hello".to_vec()),
|
||||
<StorageOf<Test>>::get(&2, &b"hello".to_vec()),
|
||||
Some(b"3".to_vec())
|
||||
);
|
||||
assert_eq!(
|
||||
<StorageOf<Test>>::get(2, b"world".to_vec()),
|
||||
<StorageOf<Test>>::get(&2, &b"world".to_vec()),
|
||||
Some(b"4".to_vec())
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user