mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-10 17:11:03 +00:00
Retire storage_items! (#3950)
* Retire storage_items * Add storage_items! tests to srml/support/tests * Assimilate genesis config
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
|
||||
use std::collections::HashMap;
|
||||
use runtime_io::{blake2_256, twox_128};
|
||||
use super::{AuthorityId, AccountId, WASM_BINARY};
|
||||
use super::{AuthorityId, AccountId, WASM_BINARY, system};
|
||||
use codec::{Encode, KeyedVec, Joiner};
|
||||
use primitives::{ChangesTrieConfiguration, map, storage::well_known_keys};
|
||||
use sr_primitives::traits::{Block as BlockT, Hash as HashT, Header as HeaderT};
|
||||
@@ -77,10 +77,16 @@ impl GenesisConfig {
|
||||
map.insert(well_known_keys::CHANGES_TRIE_CONFIG.to_vec(), changes_trie_config.encode());
|
||||
}
|
||||
map.insert(twox_128(&b"sys:auth"[..])[..].to_vec(), self.authorities.encode());
|
||||
// Finally, add the extra storage entries.
|
||||
// Add the extra storage entries.
|
||||
map.extend(self.extra_storage.clone().into_iter());
|
||||
|
||||
(map, self.child_extra_storage.clone())
|
||||
// Assimilate the system genesis config.
|
||||
let mut storage = (map, self.child_extra_storage.clone());
|
||||
let mut config = system::GenesisConfig::default();
|
||||
config.authorities = self.authorities.clone();
|
||||
config.assimilate_storage(&mut storage);
|
||||
|
||||
storage
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,12 +20,13 @@
|
||||
use rstd::prelude::*;
|
||||
use runtime_io::{storage_root, storage_changes_root, blake2_256};
|
||||
use runtime_support::storage::{self, StorageValue, StorageMap};
|
||||
use runtime_support::storage_items;
|
||||
use runtime_support::{decl_storage, decl_module};
|
||||
use sr_primitives::{
|
||||
traits::{Hash as HashT, BlakeTwo256, Header as _}, generic, ApplyError, ApplyResult,
|
||||
transaction_validity::{TransactionValidity, ValidTransaction, InvalidTransaction},
|
||||
};
|
||||
use codec::{KeyedVec, Encode};
|
||||
use srml_system::Trait;
|
||||
use crate::{
|
||||
AccountId, BlockNumber, Extrinsic, Transfer, H256 as Hash, Block, Header, Digest, AuthorityId
|
||||
};
|
||||
@@ -34,14 +35,20 @@ use primitives::storage::well_known_keys;
|
||||
const NONCE_OF: &[u8] = b"nonce:";
|
||||
const BALANCE_OF: &[u8] = b"balance:";
|
||||
|
||||
storage_items! {
|
||||
ExtrinsicData: b"sys:xtd" => required map [ u32 => Vec<u8> ];
|
||||
// The current block number being processed. Set by `execute_block`.
|
||||
Number: b"sys:num" => BlockNumber;
|
||||
ParentHash: b"sys:pha" => required Hash;
|
||||
NewAuthorities: b"sys:new_auth" => Vec<AuthorityId>;
|
||||
StorageDigest: b"sys:digest" => Digest;
|
||||
Authorities get(authorities): b"sys:auth" => default Vec<AuthorityId>;
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {}
|
||||
}
|
||||
|
||||
decl_storage! {
|
||||
trait Store for Module<T: Trait> as TestRuntime {
|
||||
ExtrinsicData: map u32 => Vec<u8>;
|
||||
// The current block number being processed. Set by `execute_block`.
|
||||
Number get(fn number): Option<BlockNumber>;
|
||||
ParentHash get(fn parent_hash): Hash;
|
||||
NewAuthorities get(fn new_authorities): Option<Vec<AuthorityId>>;
|
||||
StorageDigest get(fn storage_digest): Option<Digest>;
|
||||
Authorities get(fn authorities) config(): Vec<AuthorityId>;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn balance_of_key(who: AccountId) -> Vec<u8> {
|
||||
@@ -70,6 +77,10 @@ pub fn initialize_block(header: &Header) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn authorities() -> Vec<AuthorityId> {
|
||||
Authorities::get()
|
||||
}
|
||||
|
||||
pub fn get_block_number() -> Option<BlockNumber> {
|
||||
Number::get()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user