Use storage::append in the implementation of the storage types (#5889)

* Start improving `storage_append`

* Fix some stuff

* Fix compilation

* Update docs and add new test

* More tests

* Test kill + append
This commit is contained in:
Bastian Köcher
2020-05-05 15:09:07 +02:00
committed by GitHub
parent be0c7b9340
commit bc9707b4c5
19 changed files with 252 additions and 362 deletions
+2 -7
View File
@@ -100,9 +100,7 @@ use frame_support::{
weights::Weight,
};
use frame_system::{self as system, ensure_root, ensure_signed};
use sp_runtime::{
traits::{AtLeast32Bit, MaybeSerializeDeserialize, Zero, StaticLookup},
};
use sp_runtime::traits::{AtLeast32Bit, MaybeSerializeDeserialize, Zero, StaticLookup};
type BalanceOf<T, I> = <<T as Trait<I>>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
type PoolT<T, I> = Vec<(<T as frame_system::Trait>::AccountId, Option<<T as Trait<I>>::Score>)>;
@@ -276,10 +274,7 @@ decl_module! {
// can be inserted as last element in pool, since entities with
// `None` are always sorted to the end.
if let Err(e) = <Pool<T, I>>::append(&[(who.clone(), None)]) {
T::Currency::unreserve(&who, deposit);
Err(e)?
}
<Pool<T, I>>::append((who.clone(), Option::<<T as Trait<I>>::Score>::None));
<CandidateExists<T, I>>::insert(&who, true);