mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-03 18:07:24 +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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user