mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-22 13:51:05 +00:00
The storage runtime interface should not enforce a hash type (#4231)
* The storage runtime interface should not enforce a hash type Currently the runtime interface enforces `H256` as hash type, but in the future people could use whatever they want as hash type. The hash type always needs to match between the runtime and the node, but that is already required. * Update primitives/externalities/src/lib.rs Co-Authored-By: thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
committed by
Gavin Wood
parent
39388b826b
commit
3e26fceda4
@@ -25,7 +25,7 @@ use crate::trie_backend_essence::TrieBackendEssence;
|
||||
use crate::changes_trie::{AnchorBlockId, Configuration, Storage, BlockNumber};
|
||||
use crate::changes_trie::storage::TrieBackendAdapter;
|
||||
use crate::changes_trie::input::{ChildIndex, InputKey};
|
||||
use codec::Decode;
|
||||
use codec::{Decode, Codec};
|
||||
|
||||
/// Get number of oldest block for which changes trie is not pruned
|
||||
/// given changes trie configuration, pruning parameter and number of
|
||||
@@ -55,7 +55,7 @@ pub fn prune<S: Storage<H, Number>, H: Hasher, Number: BlockNumber, F: FnMut(H::
|
||||
min_blocks_to_keep: Number,
|
||||
current_block: &AnchorBlockId<H::Out, Number>,
|
||||
mut remove_trie_node: F,
|
||||
) {
|
||||
) where H::Out: Codec {
|
||||
|
||||
// select range for pruning
|
||||
let (first, last) = match pruning_range(config, min_blocks_to_keep, current_block.number.clone()) {
|
||||
@@ -116,7 +116,7 @@ fn prune_trie<S: Storage<H, Number>, H: Hasher, Number: BlockNumber, F: FnMut(H:
|
||||
storage: &S,
|
||||
root: H::Out,
|
||||
remove_trie_node: &mut F,
|
||||
) {
|
||||
) where H::Out: Codec {
|
||||
|
||||
// enumerate all changes trie' keys, recording all nodes that have been 'touched'
|
||||
// (effectively - all changes trie nodes)
|
||||
@@ -221,13 +221,15 @@ mod tests {
|
||||
storage: &S,
|
||||
min_blocks_to_keep: u64,
|
||||
current_block: u64,
|
||||
) -> HashSet<H::Out> {
|
||||
) -> HashSet<H::Out> where H::Out: Codec {
|
||||
let mut pruned_trie_nodes = HashSet::new();
|
||||
prune(config,
|
||||
prune(
|
||||
config,
|
||||
storage,
|
||||
min_blocks_to_keep,
|
||||
&AnchorBlockId { hash: Default::default(), number: current_block },
|
||||
|node| { pruned_trie_nodes.insert(node); });
|
||||
|node| { pruned_trie_nodes.insert(node); },
|
||||
);
|
||||
pruned_trie_nodes
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user