mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 05:51:02 +00:00
Remove BlockNumber <-> u64 conversions from light-client related code (#2666)
* Remove As usage from CHT * Remove As usage from CHT (continue) * Restrict BN <-> int conversions in CT * more BN <-> u64 conversions removed * upd spec_version * Apply suggestions from code review Co-Authored-By: Gavin Wood <github@gavwood.com> * Apply suggestions from code review Co-Authored-By: Gavin Wood <github@gavwood.com> * more grumbles * fix last grumbles + compilation * too long lines * too long lines
This commit is contained in:
committed by
Gavin Wood
parent
25b88f1a1f
commit
549d9e1da1
@@ -138,7 +138,7 @@ export_api! {
|
||||
fn child_storage_root(storage_key: &[u8]) -> Vec<u8>;
|
||||
|
||||
/// "Commit" all existing operations and get the resultant storage change root.
|
||||
fn storage_changes_root(parent_hash: [u8; 32], parent_num: u64) -> Option<[u8; 32]>;
|
||||
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))
|
||||
@@ -251,6 +251,10 @@ mod imp {
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub use self::imp::{StorageOverlay, ChildrenStorageOverlay, with_storage, with_externalities, TestExternalities};
|
||||
pub use self::imp::{StorageOverlay, ChildrenStorageOverlay, with_storage, with_externalities};
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub use self::imp::ext::*;
|
||||
|
||||
/// Type alias for Externalities implementation used in tests.
|
||||
#[cfg(feature = "std")]
|
||||
pub type TestExternalities<H> = self::imp::TestExternalities<H, u64>;
|
||||
|
||||
@@ -158,10 +158,10 @@ impl StorageApi for () {
|
||||
}).expect("child_storage_root cannot be called outside of an Externalities-provided environment.")
|
||||
}
|
||||
|
||||
fn storage_changes_root(parent_hash: [u8; 32], parent_num: u64) -> Option<[u8; 32]> {
|
||||
fn storage_changes_root(parent_hash: [u8; 32]) -> Option<[u8; 32]> {
|
||||
ext::with(|ext|
|
||||
ext.storage_changes_root(parent_hash.into(), parent_num).map(Into::into)
|
||||
).unwrap_or(None)
|
||||
ext.storage_changes_root(parent_hash.into()).map(|h| h.map(|h| h.into()))
|
||||
).unwrap_or(Ok(None)).expect("Invalid parent hash passed to storage_changes_root")
|
||||
}
|
||||
|
||||
fn enumerated_trie_root<H>(input: &[&[u8]]) -> H::Out
|
||||
|
||||
@@ -242,7 +242,7 @@ pub mod ext {
|
||||
///
|
||||
/// - `1` if the change trie root was found.
|
||||
/// - `0` if the change trie root was not found.
|
||||
fn ext_storage_changes_root(parent_hash_data: *const u8, parent_hash_len: u32, parent_num: u64, result: *mut u8) -> u32;
|
||||
fn ext_storage_changes_root(parent_hash_data: *const u8, parent_hash_len: u32, result: *mut u8) -> u32;
|
||||
|
||||
/// A child storage function.
|
||||
///
|
||||
@@ -498,10 +498,10 @@ impl StorageApi for () {
|
||||
}
|
||||
}
|
||||
|
||||
fn storage_changes_root(parent_hash: [u8; 32], parent_num: u64) -> Option<[u8; 32]> {
|
||||
fn storage_changes_root(parent_hash: [u8; 32]) -> Option<[u8; 32]> {
|
||||
let mut result: [u8; 32] = Default::default();
|
||||
let is_set = unsafe {
|
||||
ext_storage_changes_root.get()(parent_hash.as_ptr(), parent_hash.len() as u32, parent_num, result.as_mut_ptr())
|
||||
ext_storage_changes_root.get()(parent_hash.as_ptr(), parent_hash.len() as u32, result.as_mut_ptr())
|
||||
};
|
||||
|
||||
if is_set != 0 {
|
||||
|
||||
Reference in New Issue
Block a user