Introduce default-setting prime for collective (#5137)

* Introduce default-setting prime for collective

* Docs.

* Elections phragmen supports prime

* Fix

* Membership supports prime

* Fix

* Update frame/collective/src/lib.rs

Co-Authored-By: Shawn Tabrizi <shawntabrizi@gmail.com>

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
Gavin Wood
2020-03-05 15:57:03 +01:00
committed by GitHub
parent d3208aa7bc
commit 0573f1408d
7 changed files with 399 additions and 50 deletions
@@ -91,6 +91,14 @@ impl<T: FullCodec, G: StorageValue<T>> storage::StorageValue<T> for G {
unhashed::put(&Self::storage_value_final_key(), &val)
}
fn set(maybe_val: Self::Query) {
if let Some(val) = G::from_query_to_optional_value(maybe_val) {
unhashed::put(&Self::storage_value_final_key(), &val)
} else {
unhashed::kill(&Self::storage_value_final_key())
}
}
fn kill() {
unhashed::kill(&Self::storage_value_final_key())
}
@@ -73,6 +73,10 @@ pub trait StorageValue<T: FullCodec> {
/// Store a value under this key into the provided storage instance.
fn put<Arg: EncodeLike<T>>(val: Arg);
/// Store a value under this key into the provided storage instance; this uses the query
/// type rather than the underlying value.
fn set(val: Self::Query);
/// Mutate the value
fn mutate<R, F: FnOnce(&mut Self::Query) -> R>(f: F) -> R;