mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 09:37:55 +00:00
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:
@@ -870,10 +870,12 @@ macro_rules! decl_module {
|
||||
) { $( $impl:tt )* }
|
||||
) => {
|
||||
$(#[doc = $doc_attr])*
|
||||
#[allow(unreachable_code)]
|
||||
$vis fn $name(
|
||||
$origin: $origin_ty $(, $param: $param_ty )*
|
||||
) -> $crate::dispatch::Result {
|
||||
{ $( $impl )* }
|
||||
// May be unreachable.
|
||||
Ok(())
|
||||
}
|
||||
};
|
||||
@@ -1285,9 +1287,11 @@ macro_rules! impl_outer_dispatch {
|
||||
}
|
||||
$(
|
||||
impl $crate::dispatch::IsSubType<$camelcase, $runtime> for $call_type {
|
||||
#[allow(unreachable_patterns)]
|
||||
fn is_aux_sub_type(&self) -> Option<&$crate::dispatch::CallableCallFor<$camelcase, $runtime>> {
|
||||
match *self {
|
||||
$call_type::$camelcase(ref r) => Some(r),
|
||||
// May be unreachable
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
//! Abstract storage to use on HashedStorage trait
|
||||
|
||||
use crate::codec;
|
||||
use crate::codec::{self, Encode};
|
||||
use crate::rstd::prelude::{Vec, Box};
|
||||
#[cfg(feature = "std")]
|
||||
use crate::storage::unhashed::generator::UnhashedStorage;
|
||||
@@ -184,6 +184,13 @@ pub trait StorageValue<T: codec::Codec> {
|
||||
storage.put(Self::key(), val)
|
||||
}
|
||||
|
||||
/// 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).
|
||||
/// Store a value under this key into the provided storage instance.
|
||||
fn put_ref<Arg: ?Sized + Encode, S: HashedStorage<Twox128>>(val: &Arg, storage: &mut S) where T: AsRef<Arg> {
|
||||
val.using_encoded(|b| storage.put_raw(Self::key(), b))
|
||||
}
|
||||
|
||||
/// Mutate this value
|
||||
fn mutate<R, F: FnOnce(&mut Self::Query) -> R, S: HashedStorage<Twox128>>(f: F, storage: &mut S) -> R;
|
||||
|
||||
@@ -236,6 +243,17 @@ pub trait StorageMap<K: codec::Codec, V: codec::Codec> {
|
||||
storage.put(&Self::key_for(key)[..], val);
|
||||
}
|
||||
|
||||
/// 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).
|
||||
/// Store a value under this key into the provided storage instance.
|
||||
fn insert_ref<Arg: ?Sized + Encode, S: HashedStorage<Twox128>>(
|
||||
key: &K,
|
||||
val: &Arg,
|
||||
storage: &mut S
|
||||
) where V: AsRef<Arg> {
|
||||
val.using_encoded(|b| storage.put_raw(&Self::key_for(key)[..], b))
|
||||
}
|
||||
|
||||
/// Remove the value under a key.
|
||||
fn remove<S: HashedStorage<Self::Hasher>>(key: &K, storage: &mut S) {
|
||||
storage.kill(&Self::key_for(key)[..]);
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -630,3 +630,13 @@ bitmask! {
|
||||
}
|
||||
}
|
||||
|
||||
/// Trait for type that can handle incremental changes to a set of account IDs.
|
||||
pub trait ChangeMembers<AccountId> {
|
||||
/// A number of members `_incoming` just joined the set and replaced some `_outgoing` ones. The
|
||||
/// new set is thus given by `_new`.
|
||||
fn change_members(_incoming: &[AccountId], _outgoing: &[AccountId], _new: &[AccountId]);
|
||||
}
|
||||
|
||||
impl<T> ChangeMembers<T> for () {
|
||||
fn change_members(_incoming: &[T], _outgoing: &[T], _new_set: &[T]) {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user