mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 15:11:02 +00:00
update substrate reference (#244)
* port polkadot_runtime and polkadot_validation * update storages build (#245) * all tests pass * rebuild wasm
This commit is contained in:
committed by
GitHub
parent
e42019e1dc
commit
a65be1b2df
@@ -90,7 +90,7 @@ use client::{
|
||||
use sr_primitives::{
|
||||
ApplyResult, generic, transaction_validity::TransactionValidity,
|
||||
traits::{
|
||||
BlakeTwo256, Block as BlockT, DigestFor, StaticLookup, CurrencyToVoteHandler, AuthorityIdFor
|
||||
BlakeTwo256, Block as BlockT, DigestFor, StaticLookup, Convert, AuthorityIdFor
|
||||
}
|
||||
};
|
||||
use version::RuntimeVersion;
|
||||
@@ -188,6 +188,22 @@ impl session::Trait for Runtime {
|
||||
type Event = Event;
|
||||
}
|
||||
|
||||
/// Converter for currencies to votes.
|
||||
pub struct CurrencyToVoteHandler;
|
||||
|
||||
impl CurrencyToVoteHandler {
|
||||
fn factor() -> u128 { (Balances::total_issuance() / u64::max_value() as u128).max(1) }
|
||||
}
|
||||
|
||||
impl Convert<u128, u64> for CurrencyToVoteHandler {
|
||||
fn convert(x: u128) -> u64 { (x / Self::factor()) as u64 }
|
||||
}
|
||||
|
||||
impl Convert<u128, u128> for CurrencyToVoteHandler {
|
||||
fn convert(x: u128) -> u128 { x * Self::factor() }
|
||||
}
|
||||
|
||||
|
||||
impl staking::Trait for Runtime {
|
||||
type OnRewardMinted = Treasury;
|
||||
type CurrencyToVote = CurrencyToVoteHandler;
|
||||
|
||||
@@ -25,7 +25,7 @@ use primitives::Hash;
|
||||
use primitives::parachain::{Id as ParaId, Chain, DutyRoster, AttestedCandidate, Statement};
|
||||
use {system, session};
|
||||
|
||||
use srml_support::{StorageValue, StorageMap};
|
||||
use srml_support::{StorageValue, StorageMap, storage::hashed::generator};
|
||||
use srml_support::dispatch::Result;
|
||||
|
||||
use inherents::{ProvideInherent, InherentData, RuntimeString, MakeFatalError, InherentIdentifier};
|
||||
@@ -64,7 +64,7 @@ decl_storage! {
|
||||
config(parachains): Vec<(ParaId, Vec<u8>, Vec<u8>)>;
|
||||
config(_phdata): PhantomData<T>;
|
||||
build(|storage: &mut StorageOverlay, _: &mut ChildrenStorageOverlay, config: &GenesisConfig<T>| {
|
||||
use codec::Encode;
|
||||
let storage = std::cell::RefCell::new(storage);
|
||||
|
||||
let mut p = config.parachains.clone();
|
||||
p.sort_unstable_by_key(|&(ref id, _, _)| id.clone());
|
||||
@@ -72,15 +72,12 @@ decl_storage! {
|
||||
|
||||
let only_ids: Vec<_> = p.iter().map(|&(ref id, _, _)| id).cloned().collect();
|
||||
|
||||
storage.insert(Self::hash(<Parachains<T>>::key()).to_vec(), only_ids.encode());
|
||||
<Parachains<T> as generator::StorageValue<_>>::put(&only_ids, &storage);
|
||||
|
||||
for (id, code, genesis) in p {
|
||||
let code_key = Self::hash(&<Code<T>>::key_for(&id)).to_vec();
|
||||
let head_key = Self::hash(&<Heads<T>>::key_for(&id)).to_vec();
|
||||
// no ingress -- a chain cannot be routed to until it is live.
|
||||
|
||||
storage.insert(code_key, code.encode());
|
||||
storage.insert(head_key, genesis.encode());
|
||||
<Code<T> as generator::StorageMap<_, _>>::insert(&id, &code, &storage);
|
||||
<Heads<T> as generator::StorageMap<_, _>>::insert(&id, &genesis, &storage);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user