Technical Committee (#3041)

* Add copy of council seats as elections module.

* Split council into collective and elections modules.

Make collective instanceable.

* Propagate changes to the runtime and fix origin/event

* insert_ref and put_ref to avoid copies.

* Add tests

* Fix up collective's tests

* One more test

* Fix elections module tests

* Missed merge line

* Minor fix

* Test fixes

* Line widths

* Line widths

* Rntime version

* Remove comment

* Deduplicate

* Bump runtime again

* Fix test
This commit is contained in:
Gavin Wood
2019-07-10 14:29:14 +02:00
committed by GitHub
parent 8f81bd90e7
commit df93867620
19 changed files with 1958 additions and 1408 deletions
+15
View File
@@ -149,6 +149,10 @@ pub trait StorageValue<T: Codec> {
/// Store a value under this key into the provided storage instance.
fn put<Arg: Borrow<T>>(val: Arg);
/// Store a value under this key into the provided storage instance; this can take any reference
/// type that derefs to `T` (and has `Encode` implemented).
fn put_ref<Arg: ?Sized + Encode>(val: &Arg) where T: AsRef<Arg>;
/// Mutate the value
fn mutate<R, F: FnOnce(&mut Self::Query) -> R>(f: F) -> R;
@@ -180,6 +184,9 @@ impl<T: Codec, U> StorageValue<T> for U where U: hashed::generator::StorageValue
fn put<Arg: Borrow<T>>(val: Arg) {
U::put(val.borrow(), &mut RuntimeStorage)
}
fn put_ref<Arg: ?Sized + Encode>(val: &Arg) where T: AsRef<Arg> {
U::put_ref(val, &mut RuntimeStorage)
}
fn mutate<R, F: FnOnce(&mut Self::Query) -> R>(f: F) -> R {
U::mutate(f, &mut RuntimeStorage)
}
@@ -216,6 +223,10 @@ pub trait StorageMap<K: Codec, V: Codec> {
/// Store a value to be associated with the given key from the map.
fn insert<KeyArg: Borrow<K>, ValArg: Borrow<V>>(key: KeyArg, val: ValArg);
/// Store a value under this key into the provided storage instance; this can take any reference
/// type that derefs to `T` (and has `Encode` implemented).
fn insert_ref<KeyArg: Borrow<K>, ValArg: ?Sized + Encode>(key: KeyArg, val: &ValArg) where V: AsRef<ValArg>;
/// Remove the value under a key.
fn remove<KeyArg: Borrow<K>>(key: KeyArg);
@@ -249,6 +260,10 @@ impl<K: Codec, V: Codec, U> StorageMap<K, V> for U where U: hashed::generator::S
U::insert(key.borrow(), val.borrow(), &mut RuntimeStorage)
}
fn insert_ref<KeyArg: Borrow<K>, ValArg: ?Sized + Encode>(key: KeyArg, val: &ValArg) where V: AsRef<ValArg> {
U::insert_ref(key.borrow(), val, &mut RuntimeStorage)
}
fn remove<KeyArg: Borrow<K>>(key: KeyArg) {
U::remove(key.borrow(), &mut RuntimeStorage)
}