mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 04:41:02 +00:00
This commit is contained in:
@@ -153,15 +153,6 @@ export_api! {
|
||||
/// "Commit" all existing operations and get the resultant storage change root.
|
||||
fn storage_changes_root(parent_hash: [u8; 32]) -> Option<[u8; 32]>;
|
||||
|
||||
/// A trie root formed from the enumerated items.
|
||||
/// TODO [#2382] remove (just use `ordered_trie_root` (NOTE currently not implemented for without_std))
|
||||
fn enumerated_trie_root<H>(input: &[&[u8]]) -> H::Out
|
||||
where
|
||||
H: Hasher,
|
||||
H: self::imp::HasherBounds,
|
||||
H::Out: Ord
|
||||
;
|
||||
|
||||
/// A trie root formed from the iterated items.
|
||||
fn trie_root<H, I, A, B>(input: I) -> H::Out
|
||||
where
|
||||
|
||||
@@ -167,14 +167,6 @@ impl StorageApi for () {
|
||||
).unwrap_or(Ok(None)).expect("Invalid parent hash passed to storage_changes_root")
|
||||
}
|
||||
|
||||
fn enumerated_trie_root<H>(input: &[&[u8]]) -> H::Out
|
||||
where
|
||||
H: Hasher,
|
||||
H::Out: Ord,
|
||||
{
|
||||
Layout::<H>::ordered_trie_root(input)
|
||||
}
|
||||
|
||||
fn trie_root<H, I, A, B>(input: I) -> H::Out
|
||||
where
|
||||
I: IntoIterator<Item = (A, B)>,
|
||||
|
||||
@@ -128,8 +128,11 @@ pub mod ext {
|
||||
|
||||
/// Ensures we use the right crypto when calling into native
|
||||
pub trait ExternTrieCrypto: Hasher {
|
||||
/// Calculate enumerated trie root.
|
||||
fn enumerated_trie_root(values: &[&[u8]]) -> Self::Out;
|
||||
/// A trie root formed from the enumerated items.
|
||||
fn ordered_trie_root<
|
||||
A: AsRef<[u8]>,
|
||||
I: IntoIterator<Item = A>
|
||||
>(values: I) -> Self::Out;
|
||||
}
|
||||
|
||||
/// Additional bounds for Hasher trait for without_std.
|
||||
@@ -138,9 +141,16 @@ pub mod ext {
|
||||
|
||||
// Ensures we use a Blake2_256-flavored Hasher when calling into native
|
||||
impl ExternTrieCrypto for Blake2Hasher {
|
||||
fn enumerated_trie_root(values: &[&[u8]]) -> Self::Out {
|
||||
let lengths = values.iter().map(|v| (v.len() as u32).to_le()).collect::<Vec<_>>();
|
||||
let values = values.iter().fold(Vec::new(), |mut acc, sl| { acc.extend_from_slice(sl); acc });
|
||||
fn ordered_trie_root<
|
||||
A: AsRef<[u8]>,
|
||||
I: IntoIterator<Item = A>
|
||||
>(items: I) -> Self::Out {
|
||||
let mut values = Vec::new();
|
||||
let mut lengths = Vec::new();
|
||||
for v in items.into_iter() {
|
||||
values.extend_from_slice(v.as_ref());
|
||||
lengths.push((v.as_ref().len() as u32).to_le());
|
||||
}
|
||||
let mut result: [u8; 32] = Default::default();
|
||||
unsafe {
|
||||
ext_blake2_256_enumerated_trie_root.get()(
|
||||
@@ -767,10 +777,6 @@ impl StorageApi for () {
|
||||
}
|
||||
}
|
||||
|
||||
fn enumerated_trie_root<H: Hasher + ExternTrieCrypto>(values: &[&[u8]]) -> H::Out {
|
||||
H::enumerated_trie_root(values)
|
||||
}
|
||||
|
||||
fn trie_root<
|
||||
H: Hasher + ExternTrieCrypto,
|
||||
I: IntoIterator<Item = (A, B)>,
|
||||
@@ -784,8 +790,8 @@ impl StorageApi for () {
|
||||
H: Hasher + ExternTrieCrypto,
|
||||
I: IntoIterator<Item = A>,
|
||||
A: AsRef<[u8]>
|
||||
>(_input: I) -> H::Out {
|
||||
unimplemented!()
|
||||
>(values: I) -> H::Out {
|
||||
H::ordered_trie_root(values)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user