mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 14:27:57 +00:00
Introduce function into frame System (#14149)
This commit is contained in:
@@ -66,6 +66,7 @@
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use serde::Serialize;
|
||||
use sp_io::hashing::blake2_256;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
use sp_runtime::traits::TrailingZeroInput;
|
||||
use sp_runtime::{
|
||||
@@ -1316,6 +1317,8 @@ impl<T: Config> Pallet<T> {
|
||||
// populate environment
|
||||
ExecutionPhase::<T>::put(Phase::Initialization);
|
||||
storage::unhashed::put(well_known_keys::EXTRINSIC_INDEX, &0u32);
|
||||
let entropy = (b"frame_system::initialize", parent_hash).using_encoded(blake2_256);
|
||||
storage::unhashed::put(well_known_keys::INTRABLOCK_ENTROPY, &entropy[..]);
|
||||
<Number<T>>::put(number);
|
||||
<Digest<T>>::put(digest);
|
||||
<ParentHash<T>>::put(parent_hash);
|
||||
@@ -1365,6 +1368,7 @@ impl<T: Config> Pallet<T> {
|
||||
);
|
||||
ExecutionPhase::<T>::kill();
|
||||
AllExtrinsicsLen::<T>::kill();
|
||||
storage::unhashed::kill(well_known_keys::INTRABLOCK_ENTROPY);
|
||||
|
||||
// The following fields
|
||||
//
|
||||
@@ -1633,6 +1637,16 @@ impl<T: Config> Pallet<T> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a 32 byte datum which is guaranteed to be universally unique. `entropy` is provided
|
||||
/// as a facility to reduce the potential for precalculating results.
|
||||
pub fn unique(entropy: impl Encode) -> [u8; 32] {
|
||||
let mut last = [0u8; 32];
|
||||
sp_io::storage::read(well_known_keys::INTRABLOCK_ENTROPY, &mut last[..], 0);
|
||||
let next = (b"frame_system::unique", entropy, last).using_encoded(blake2_256);
|
||||
sp_io::storage::set(well_known_keys::INTRABLOCK_ENTROPY, &next.encode());
|
||||
next
|
||||
}
|
||||
|
||||
/// Event handler which registers a provider when created.
|
||||
pub struct Provider<T>(PhantomData<T>);
|
||||
impl<T: Config> HandleLifetime<T::AccountId> for Provider<T> {
|
||||
|
||||
Reference in New Issue
Block a user