mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-20 10:25:41 +00:00
Take genesis_storage by ref (#4617)
Instead of having these weird implementation of `BuildStorage for &ChainSpec` we should just take the `genesis_storage` by ref. The `BuildStorage` trait changed some time ago to take a self ref anyway, instead of a self value. Also fixes warnings in frame-staking
This commit is contained in:
@@ -70,7 +70,7 @@ impl<G: RuntimeGenesis> GenesisSource<G> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, G: RuntimeGenesis, E> BuildStorage for &'a ChainSpec<G, E> {
|
impl<G: RuntimeGenesis, E> BuildStorage for ChainSpec<G, E> {
|
||||||
fn build_storage(&self) -> Result<Storage, String> {
|
fn build_storage(&self) -> Result<Storage, String> {
|
||||||
match self.genesis.resolve()? {
|
match self.genesis.resolve()? {
|
||||||
Genesis::Runtime(gc) => gc.build_storage(),
|
Genesis::Runtime(gc) => gc.build_storage(),
|
||||||
|
|||||||
@@ -274,7 +274,7 @@ pub enum DatabaseSettingsSrc {
|
|||||||
pub fn new_client<E, S, Block, RA>(
|
pub fn new_client<E, S, Block, RA>(
|
||||||
settings: DatabaseSettings,
|
settings: DatabaseSettings,
|
||||||
executor: E,
|
executor: E,
|
||||||
genesis_storage: S,
|
genesis_storage: &S,
|
||||||
fork_blocks: ForkBlocks<Block>,
|
fork_blocks: ForkBlocks<Block>,
|
||||||
bad_blocks: BadBlocks<Block>,
|
bad_blocks: BadBlocks<Block>,
|
||||||
execution_extensions: ExecutionExtensions<Block>,
|
execution_extensions: ExecutionExtensions<Block>,
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ impl<H> PrePostHeader<H> {
|
|||||||
/// Create an instance of in-memory client.
|
/// Create an instance of in-memory client.
|
||||||
pub fn new_in_mem<E, Block, S, RA>(
|
pub fn new_in_mem<E, Block, S, RA>(
|
||||||
executor: E,
|
executor: E,
|
||||||
genesis_storage: S,
|
genesis_storage: &S,
|
||||||
keystore: Option<sp_core::traits::BareCryptoStorePtr>,
|
keystore: Option<sp_core::traits::BareCryptoStorePtr>,
|
||||||
) -> sp_blockchain::Result<Client<
|
) -> sp_blockchain::Result<Client<
|
||||||
in_mem::Backend<Block>,
|
in_mem::Backend<Block>,
|
||||||
@@ -149,7 +149,7 @@ pub fn new_in_mem<E, Block, S, RA>(
|
|||||||
pub fn new_with_backend<B, E, Block, S, RA>(
|
pub fn new_with_backend<B, E, Block, S, RA>(
|
||||||
backend: Arc<B>,
|
backend: Arc<B>,
|
||||||
executor: E,
|
executor: E,
|
||||||
build_genesis_storage: S,
|
build_genesis_storage: &S,
|
||||||
keystore: Option<sp_core::traits::BareCryptoStorePtr>,
|
keystore: Option<sp_core::traits::BareCryptoStorePtr>,
|
||||||
) -> sp_blockchain::Result<Client<B, LocalCallExecutor<B, E>, Block, RA>>
|
) -> sp_blockchain::Result<Client<B, LocalCallExecutor<B, E>, Block, RA>>
|
||||||
where
|
where
|
||||||
@@ -187,7 +187,7 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
|
|||||||
pub fn new<S: BuildStorage>(
|
pub fn new<S: BuildStorage>(
|
||||||
backend: Arc<B>,
|
backend: Arc<B>,
|
||||||
executor: E,
|
executor: E,
|
||||||
build_genesis_storage: S,
|
build_genesis_storage: &S,
|
||||||
fork_blocks: ForkBlocks<Block>,
|
fork_blocks: ForkBlocks<Block>,
|
||||||
bad_blocks: BadBlocks<Block>,
|
bad_blocks: BadBlocks<Block>,
|
||||||
execution_extensions: ExecutionExtensions<Block>,
|
execution_extensions: ExecutionExtensions<Block>,
|
||||||
|
|||||||
@@ -65,7 +65,7 @@
|
|||||||
//! NativeExecutor::<LocalExecutor>::new(WasmExecutionMethod::Interpreted, None),
|
//! NativeExecutor::<LocalExecutor>::new(WasmExecutionMethod::Interpreted, None),
|
||||||
//! ),
|
//! ),
|
||||||
//! // This parameter provides the storage for the chain genesis.
|
//! // This parameter provides the storage for the chain genesis.
|
||||||
//! <Storage>::default(),
|
//! &<Storage>::default(),
|
||||||
//! Default::default(),
|
//! Default::default(),
|
||||||
//! Default::default(),
|
//! Default::default(),
|
||||||
//! Default::default(),
|
//! Default::default(),
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ pub fn new_light_backend<B, S>(blockchain: Arc<Blockchain<S>>) -> Arc<Backend<S,
|
|||||||
/// Create an instance of light client.
|
/// Create an instance of light client.
|
||||||
pub fn new_light<B, S, GS, RA, E>(
|
pub fn new_light<B, S, GS, RA, E>(
|
||||||
backend: Arc<Backend<S, HasherFor<B>>>,
|
backend: Arc<Backend<S, HasherFor<B>>>,
|
||||||
genesis_storage: GS,
|
genesis_storage: &GS,
|
||||||
code_executor: E,
|
code_executor: E,
|
||||||
) -> ClientResult<
|
) -> ClientResult<
|
||||||
Client<
|
Client<
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ use sp_staking::{
|
|||||||
use sp_runtime::{Serialize, Deserialize};
|
use sp_runtime::{Serialize, Deserialize};
|
||||||
use frame_system::{self as system, ensure_signed, ensure_root};
|
use frame_system::{self as system, ensure_signed, ensure_root};
|
||||||
|
|
||||||
use sp_phragmen::{ExtendedBalance, PhragmenStakedAssignment};
|
use sp_phragmen::ExtendedBalance;
|
||||||
|
|
||||||
const DEFAULT_MINIMUM_VALIDATOR_COUNT: u32 = 4;
|
const DEFAULT_MINIMUM_VALIDATOR_COUNT: u32 = 4;
|
||||||
const MAX_NOMINATIONS: usize = 16;
|
const MAX_NOMINATIONS: usize = 16;
|
||||||
@@ -1508,12 +1508,10 @@ impl<T: Trait> Module<T> {
|
|||||||
.collect::<Vec<T::AccountId>>();
|
.collect::<Vec<T::AccountId>>();
|
||||||
let assignments = phragmen_result.assignments;
|
let assignments = phragmen_result.assignments;
|
||||||
|
|
||||||
let to_votes = |b: BalanceOf<T>|
|
|
||||||
<T::CurrencyToVote as Convert<BalanceOf<T>, u64>>::convert(b) as ExtendedBalance;
|
|
||||||
let to_balance = |e: ExtendedBalance|
|
let to_balance = |e: ExtendedBalance|
|
||||||
<T::CurrencyToVote as Convert<ExtendedBalance, BalanceOf<T>>>::convert(e);
|
<T::CurrencyToVote as Convert<ExtendedBalance, BalanceOf<T>>>::convert(e);
|
||||||
|
|
||||||
let mut supports = sp_phragmen::build_support_map::<_, _, _, T::CurrencyToVote>(
|
let supports = sp_phragmen::build_support_map::<_, _, _, T::CurrencyToVote>(
|
||||||
&elected_stashes,
|
&elected_stashes,
|
||||||
&assignments,
|
&assignments,
|
||||||
Self::slashable_balance_of,
|
Self::slashable_balance_of,
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ impl<Executor, Backend, G: GenesisInit> TestClientBuilder<Executor, Backend, G>
|
|||||||
let client = sc_client::Client::new(
|
let client = sc_client::Client::new(
|
||||||
self.backend.clone(),
|
self.backend.clone(),
|
||||||
executor,
|
executor,
|
||||||
storage,
|
&storage,
|
||||||
Default::default(),
|
Default::default(),
|
||||||
Default::default(),
|
Default::default(),
|
||||||
ExecutionExtensions::new(
|
ExecutionExtensions::new(
|
||||||
|
|||||||
Reference in New Issue
Block a user