mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 18:11:10 +00:00
This PR adds support for fetching the closest merkle value of some key. Builds on top of - https://github.com/paritytech/trie/pull/199 Migrates https://github.com/paritytech/substrate/pull/14818 to the monorepo. Closes: https://github.com/paritytech/substrate/issues/14550 Closes: https://github.com/paritytech/polkadot-sdk/issues/1506 // @paritytech/subxt-team --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by: Sebastian Kunert <skunert49@gmail.com>
This commit is contained in:
@@ -78,7 +78,7 @@ use sp_state_machine::{
|
||||
ChildStorageCollection, KeyValueStates, KeyValueStorageLevel, StorageCollection,
|
||||
MAX_NESTED_TRIE_DEPTH,
|
||||
};
|
||||
use sp_trie::{CompactProof, StorageProof};
|
||||
use sp_trie::{CompactProof, MerkleValue, StorageProof};
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
marker::PhantomData,
|
||||
@@ -1545,6 +1545,27 @@ where
|
||||
.child_storage_hash(child_info, &key.0)
|
||||
.map_err(|e| sp_blockchain::Error::from_state(Box::new(e)))
|
||||
}
|
||||
|
||||
fn closest_merkle_value(
|
||||
&self,
|
||||
hash: <Block as BlockT>::Hash,
|
||||
key: &StorageKey,
|
||||
) -> blockchain::Result<Option<MerkleValue<<Block as BlockT>::Hash>>> {
|
||||
self.state_at(hash)?
|
||||
.closest_merkle_value(&key.0)
|
||||
.map_err(|e| sp_blockchain::Error::from_state(Box::new(e)))
|
||||
}
|
||||
|
||||
fn child_closest_merkle_value(
|
||||
&self,
|
||||
hash: <Block as BlockT>::Hash,
|
||||
child_info: &ChildInfo,
|
||||
key: &StorageKey,
|
||||
) -> blockchain::Result<Option<MerkleValue<<Block as BlockT>::Hash>>> {
|
||||
self.state_at(hash)?
|
||||
.child_closest_merkle_value(child_info, &key.0)
|
||||
.map_err(|e| sp_blockchain::Error::from_state(Box::new(e)))
|
||||
}
|
||||
}
|
||||
|
||||
impl<B, E, Block, RA> HeaderMetadata<Block> for Client<B, E, Block, RA>
|
||||
|
||||
Reference in New Issue
Block a user